public void Update(Customer customer) { CustomerEntity currentEntity = _context.CustomerEntity.Find(customer.CustomerId); var newEntity = new CustomerEntity { FirstName = customer.FirstName, LastName = customer.LastName, CustomerId = currentEntity.CustomerId }; _context.Entry(currentEntity).CurrentValues.SetValues(newEntity); _context.SaveChanges(); }
public void Update(Inventory inventory) { InventoryEntity currentEntity = _context.InventoryEntity.Find(inventory.LocationId, inventory.ProductId); int newAmount = currentEntity.Amount - inventory.Amount; var newEntity = new InventoryEntity { Amount = newAmount, LocationId = currentEntity.LocationId, ProductId = currentEntity.ProductId }; _context.Entry(currentEntity).CurrentValues.SetValues(newEntity); _context.SaveChanges(); }