Advertisement
Guest User

Untitled

a guest
Dec 20th, 2015
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace DataAccess
  2. {
  3.     public class Database : IDatabase
  4.     {
  5.         Connection connection;
  6.         string Name;
  7.         public Database(string name)
  8.         {
  9.             this.Name = name;
  10.         }
  11.  
  12.         public IConnection GetNewConnection(string userName, string password)
  13.         {
  14.              connection = new Connection(userName, password);
  15.             connection.Open();
  16.             return connection;
  17.         }
  18.  
  19.         public List<Dictionary<string, object>> GetData(IConnection connection)
  20.         {
  21.             if (this.connection.IsOpen() == false)
  22.             {
  23.                 throw new ConnectionClosedException();
  24.             }
  25.             else
  26.             {
  27.                 List<Dictionary<string, object>> t = new List<Dictionary<string, object>>();
  28.                 for (int i = 1; i < 10; i++)
  29.                 {
  30.                     Dictionary<string, object> d = new Dictionary<string, object>();
  31.                     d.Add("pesel: ", i);
  32.                     d.Add("imię: ", "imię_" + i);
  33.                     d.Add("nazwisko: ", "nazwisko_" + i);
  34.                     t.Add(d);
  35.                 }
  36.                 return t;
  37.             }
  38.            
  39.            
  40.         }
  41.  
  42.         public string GetDatabaseName()
  43.         {
  44.             return Name;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement