//Метод сохранения заказов public void SaveBKOrder(BKOrder order) { context.AttachRange(order.Lines.Select(l => l.BurgerKing)); if (order.Id == 0) { context.BKOrders.Add(order); } context.SaveChanges(); }
public IActionResult MarkShipped(int id) { BKOrder bKOrder = repository.BKOrders.FirstOrDefault(o => o.Id == id); if (bKOrder != null) { bKOrder.Shipped = true; repository.SaveBKOrder(bKOrder); } return(RedirectToAction(nameof(ListOrder))); }
public IActionResult Checkout(BKOrder order) { if (cart.Lines.Count() == 0) { ModelState.AddModelError("", "Извините ваша корзина пуста"); } if (ModelState.IsValid) { order.Lines = cart.Lines.ToArray(); repository.SaveBKOrder(order); cart.Clear(); return(RedirectToAction(nameof(Completed))); } else { return(View(order)); } }