Exemplo n.º 1
0
        List <Customer> ICustomerRepositary.GetAll()
        {
            CustomersEntities entities  = new CustomersEntities();
            List <Customer>   customers = entities.Customers.ToList();

            return(customers);
        }
Exemplo n.º 2
0
        Customer ICustomerRepositary.Create(Customer customer)
        {
            using (CustomersEntities entities = new CustomersEntities())
            {
                entities.Customers.Add(customer);
                entities.SaveChanges();
            }

            return(customer);
        }
Exemplo n.º 3
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();
     }
 }
Exemplo n.º 4
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();
     }
 }