public void RemoveCustomer(int id) { Entities.Customer customer = _context.Customer.Find(id); if (customer != null) { _context.Customer.Remove(customer); Log.Information($"Customer with Id {customer.CustomerId} has been deleted."); } else { Log.Error($"Customer with Id {customer.CustomerId} could not be deleted because it does not exist."); } }
public void UpdateCustomer(Customer customer) { Entities.Customer currentCustomer = _context.Customer.Find(customer.CustomerId); if (currentCustomer != null) { Entities.Customer newCustomer = Mapper.MapCustomer(customer); _context.Entry(currentCustomer).CurrentValues.SetValues(newCustomer); Log.Information($"Customer with Id {customer.CustomerId} has been updated."); } else { Log.Error($"Customer with Id {customer.CustomerId} could not be updated because it does not exist."); } }
public void AddCustomer(Customer customer) { Entities.Customer newCustomer = Mapper.MapCustomer(customer); _context.Customer.Add(newCustomer); }