Beispiel #1
0
 /// <summary>
 /// Deletes the entity.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="databaseEntity">The database entity.</param>
 public void DeleteEntity <T>(T databaseEntity)
 {
     if (databaseEntity is DatabaseCustomer)
     {
         DatabaseCustomer dbCustomer            = databaseEntity as DatabaseCustomer;
         DatabaseCustomer dbCustomerToBeDeleted = (from c in DatabaseCustomers where c.Id == dbCustomer.Id select c).FirstOrDefault();
         DatabaseCustomers.Remove(dbCustomerToBeDeleted);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Adds the entity.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="databaseEntity">The database entity.</param>
 public void AddEntity <T>(T databaseEntity)
 {
     if (databaseEntity is DatabaseCustomer)
     {
         DatabaseCustomer databaseCustomer = databaseEntity as DatabaseCustomer;
         databaseCustomer.Id = DatabaseCustomers.Count + 1;
         DatabaseCustomers.Add(databaseEntity as DatabaseCustomer);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Updates the entity.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="databaseEntity">The database entity.</param>
 public void UpdateEntity <T>(T databaseEntity)
 {
     if (databaseEntity is DatabaseCustomer)
     {
         DatabaseCustomer dbCustomer            = databaseEntity as DatabaseCustomer;
         DatabaseCustomer dbCustomerToBeUpdated = (from c in DatabaseCustomers where c.Id == dbCustomer.Id select c).FirstOrDefault();
         dbCustomerToBeUpdated.Address      = dbCustomer.Address;
         dbCustomerToBeUpdated.City         = dbCustomer.City;
         dbCustomerToBeUpdated.Country      = dbCustomer.Country;
         dbCustomerToBeUpdated.CustomerName = dbCustomer.CustomerName;
         dbCustomerToBeUpdated.Telephone    = dbCustomer.Telephone;
     }
 }