Exemplo n.º 1
0
 public void AddCustomer(Customer customer)
 {
     using (var _db = new CRUDEFEntities()) {
         _db.Customers.Add(customer);
         _db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void UpdateCustomer(Customer customer)
 {
     using (var _db = new CRUDEFEntities()) {
         var customer_temp = _db.Customers.SingleOrDefault(c => c.CustomerID == customer.CustomerID);
         _db.Entry(customer_temp).CurrentValues.SetValues(customer);
         _db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public List<Customer> GetAllCustomers()
 {
     using (var _db = new CRUDEFEntities()) {
         IQueryable<Customer> list = from c in _db.Customers
                                     select c;
         return list.ToList();
     }
 }
Exemplo n.º 4
0
 public void DeleteCustomer(int idCustomer)
 {
     using (var _db = new CRUDEFEntities()) {
         var currentCustomer = _db.Customers.SingleOrDefault(c => c.CustomerID == idCustomer);
         _db.Entry(currentCustomer).State = System.Data.Entity.EntityState.Deleted;
         _db.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public Customer GetCustomerByID(int idCustomer)
 {
     using (var _db = new CRUDEFEntities())
     {
         var currentCustomer = from c in _db.Customers
                                     where c.CustomerID.Equals(idCustomer)
                                     select c;
         return currentCustomer.Single();
     }
 }