public static Model.Customer MapCustomer(Project1.Domain.Model.Customer customer) { return(new Model.Customer { CustomerId = customer.CustomerId, FirstName = customer.FirstName, LastName = customer.LastName, Email = customer.Email, OrderHistory = new List <Model.OrderHistory>() }); }
public void UpdateCustomer(Project1.Domain.Model.Customer customer) { _logger.LogInformation("Updating customer with ID {customerId}", customer.CustomerId); // calling Update would mark every property as Modified. // this way will only mark the changed properties as Modified. Project1.Domain.Model.Customer entity = _dbContext.Customer.First(c => c.CustomerId == customer.CustomerId); Model.Customer newEntity = Mapper.MapCustomer(entity); _dbContext.Entry(newEntity).CurrentValues.SetValues(customer); }
/// <summary> /// Add /// </summary> /// <param name="customer"></param> public void AddCustomer(Project1.Domain.Model.Customer customer) { if (customer.CustomerId > 0) { _logger.LogWarning("Customer to be added has an ID ({customerId}) already: ignoring.", customer.CustomerId); } else { _logger.LogInformation("Adding customer"); } Model.Customer entity = Mapper.MapCustomer(customer); entity.CustomerId = 0; _dbContext.Add(entity); }
public IEnumerable <Project1.Domain.Model.StoreOrder> GetCustomerOrders(Project1.Domain.Model.Customer customer) { throw new NotImplementedException(); }
public void RemoveCustomer(Project1.Domain.Model.Customer customer) { throw new NotImplementedException(); }