public static bool SetCrustInventory(List <pi.Crust> crusts, int locationId, int stock) { foreach (var crust in crusts) { var dataCrust = new CrustInventory() { CrustId = crust.CrustId, LocationId = locationId, Stock = stock }; _db.CrustInventory.Add(dataCrust); } return(_db.SaveChanges() == 4); }
public static void InitLocationInventory(int locationId) { var crusts = GetCrusts(); var sizes = GetSizes(); var toppings = GetToppings(); var defaultStock = 10; foreach (var crust in crusts) { var dataCrust = new CrustInventory() { CrustId = crust.CrustId, LocationId = locationId, Stock = defaultStock }; _db.CrustInventory.Add(dataCrust); } foreach (var size in sizes) { var dataSize = new SizeInventory() { SizeId = size.SizeId, LocationId = locationId, Stock = defaultStock }; _db.SizeInventory.Add(dataSize); } foreach (var topping in toppings) { var dataTopping = new ToppingInventory() { ToppingId = topping.ToppingId, LocationId = locationId, Stock = defaultStock }; _db.ToppingInventory.Add(dataTopping); } }