public void Update(InventoryLocation inventoryLocation) { var inventoryLocationToUpdate = _dbcontext.InventoryLocations .FirstOrDefault(x => x.Id == inventoryLocation.Id && x.CompanyId == inventoryLocation.CompanyId); if (inventoryLocationToUpdate == null) { throw new DataNotFoundException("InventoryLocation not found."); } inventoryLocationToUpdate.Name = inventoryLocation.Name; _dbcontext.Update(inventoryLocationToUpdate); _dbcontext.SaveChanges(); }
public int Add(InventoryLocation inventoryLocation) { _dbcontext.InventoryLocations.Add(inventoryLocation); _dbcontext.SaveChanges(); return(inventoryLocation.Id); }