public Customer Add(Customer customer) { using (var context = new DemoContextFactory().Create()) { _customers.Add(customer); context.SaveChanges(); } //todo: add Id field return(customer); }
public Customer Delete(int id) { Customer itemToRemove; using (var context = new DemoContextFactory().Create()) { _customers = context.Customers.ToList(); itemToRemove = _customers.SingleOrDefault(c => c.CustomerId == id); if (itemToRemove != null) { //_customers.Remove(itemToRemove); context.Customers.Remove(itemToRemove); context.SaveChanges(); } } return(itemToRemove); }