public void RemoveLocation(int id) { Entities.Location location = _context.Location.Find(id); if (location != null) { _context.Location.Remove(location); Log.Information($"Location with Id {location.LocationId} has been deleted."); } else { Log.Error($"Location with Id {location.LocationId} could not be removed because it does not exist."); } }
public void UpdateLocation(Location location) { Entities.Location currentLocation = _context.Location .Include(l => l.Inventory).FirstOrDefault(l => l.LocationId == location.LocationId); if (currentLocation != null) { foreach (Entities.Inventory item in currentLocation.Inventory) { item.Quantity = location.Inventory.Find(i => i.Component.ComponentId == item.ComponentId).Quantity; } Log.Information($"Location with Id {location.LocationId} has been updated."); } else { Log.Error($"Location with Id {location.LocationId} could not be updated because it does not exist."); } }
public void AddLocation(Location location) { Entities.Location newLocation = Mapper.MapLocation(location); _context.Location.Add(newLocation); }