Exemplo n.º 1
0
        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.");
            }
        }
Exemplo n.º 2
0
        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.");
            }
        }
Exemplo n.º 3
0
 public void AddCustomer(Customer customer)
 {
     Entities.Customer newCustomer = Mapper.MapCustomer(customer);
     _context.Customer.Add(newCustomer);
 }