Exemple #1
0
        Customer ICustomerRepositary.Create(Customer customer)
        {
            using (CustomersEntities entities = new CustomersEntities())
            {
                entities.Customers.Add(customer);
                entities.SaveChanges();
            }

            return(customer);
        }
Exemple #2
0
 void ICustomerRepositary.Delete(int customerId)
 {
     using (CustomersEntities entities = new CustomersEntities())
     {
         Customer customer = (from c in entities.Customers
                              where c.CustomerId == customerId
                              select c).FirstOrDefault();
         entities.Customers.Remove(customer);
         entities.SaveChanges();
     }
 }
Exemple #3
0
 void ICustomerRepositary.Update(Customer customer)
 {
     using (CustomersEntities entities = new CustomersEntities())
     {
         Customer updatedCustomer = (from c in entities.Customers
                                     where c.CustomerId == customer.CustomerId
                                     select c).FirstOrDefault();
         updatedCustomer.FirstName   = customer.FirstName;
         updatedCustomer.LastName    = customer.LastName;
         updatedCustomer.Email       = customer.Email;
         updatedCustomer.PhoneNumber = customer.PhoneNumber;
         updatedCustomer.Status      = customer.Status.Value;
         entities.SaveChanges();
     }
 }