public ActionResult <Orders> Post(Order NewItem) { Locations loc = Repo.GetLocationByCity(NewItem.Location); Users u = Repo.GetUserByUsername(NewItem.Username); Orders order = new Orders { LocationId = loc.Id, OrderTime = DateTime.Now, UserId = u.UserId }; Repo.AddOrderAsync(order); return(NoContent()); }
public async Task JustDoMAgic(BigOrder value) { //order bit Users u = Repo.GetUserByUsername(value.user); Locations l = Repo.GetLocationByCity(value.Location); Orders o; if (value.CustomBurgerYes) { o = new Orders { UserId = u.UserId, LocationId = l.Id, OrderTime = value.OrderTime, Cost = 5 * (value.QuantityBurger + value.QuantityCocktail + value.QuantityDraft_Beer + value.QuantityOfBurger + value.QuantityTaco + value.QuantityWrap + 11) }; } else { o = new Orders { UserId = u.UserId, LocationId = l.Id, OrderTime = value.OrderTime, Cost = 5 * (value.QuantityBurger + value.QuantityCocktail + value.QuantityDraft_Beer + value.QuantityOfBurger + value.QuantityTaco + value.QuantityWrap) }; } await Repo.AddOrderAsync(o); //order bit //items into order Orders LastOrderOfUser = await Repo.FindLastOrderOfUserAsync(u.UserId); await addPreMadeItem(value.burger, value.QuantityOfBurger, "Burger", LastOrderOfUser.OrderId, l.Id); await addPreMadeItem(value.CockTail, value.QuantityCocktail, "Cocktail", LastOrderOfUser.OrderId, l.Id); await addPreMadeItem(value.Draft_Beer, value.QuantityDraft_Beer, "Draft Beer", LastOrderOfUser.OrderId, l.Id); await addPreMadeItem(value.Taco, value.QuantityTaco, "Taco", LastOrderOfUser.OrderId, l.Id); await addPreMadeItem(value.wrap, value.QuantityWrap, "Wrap", LastOrderOfUser.OrderId, l.Id); //items into order if (value.CustomBurgerYes) { await addCustomBurger(value.CustomBurgerYes, value.Custom_Burger, LastOrderOfUser.OrderId); var cb = await Repo.getLastCustom(value.Custom_Burger); var buns = await Repo.GetInventoriesByNameAsync("buns"); var patties = await Repo.GetInventoriesByNameAsync("patties"); var cheese = await Repo.GetInventoriesByNameAsync("cheese"); var Inv = await Repo.GetInventoriesByNameAsync(value.ingredient); var Inv1 = await Repo.GetInventoriesByNameAsync(value.ingredient1); var Inv2 = await Repo.GetInventoriesByNameAsync(value.ingredient2); var Inv3 = await Repo.GetInventoriesByNameAsync(value.ingredient3); await CustomUsesInventory(cb.Id, buns.Id); await CustomUsesInventory(cb.Id, patties.Id); await CustomUsesInventory(cb.Id, cheese.Id); await CustomUsesInventory(cb.Id, Inv.Id); await CustomUsesInventory(cb.Id, Inv1.Id); await CustomUsesInventory(cb.Id, Inv2.Id); await CustomUsesInventory(cb.Id, Inv3.Id); await addinv(l.Id, buns.Id); await addinv(l.Id, patties.Id); await addinv(l.Id, cheese.Id); await addinv(l.Id, Inv.Id); await addinv(l.Id, Inv1.Id); await addinv(l.Id, Inv2.Id); await addinv(l.Id, Inv3.Id); } }