public IActionResult EditOrder(int orderId, string name) { using (_context) { OrderManage order = new OrderManage(orderId, name); //Ensure order exists order.GetOrder(_context); if (order.order != null) { //Sets up the basket with the list of items in the order. Basket basket = new Basket(); basket.SetToOrder(_context, order.OrderId); CookieManager.SetCookie("Basket", basket.GetSerialised(), Response); //Set EditOrder Cookie: Holding the order id and name used to later save any changes. CookieManager.SetCookie("EditOrder", order.GetSerialised(), Response); } return(RedirectToAction("Index")); } }
public IActionResult ViewOrder(OrderManage orderDetail) { using (_context) { if (ModelState.IsValid) { //Checking the order exists and information is correct. orderDetail.GetOrder(_context); if (orderDetail.order != null) { //Gets all the details on the order to display. ViewData["OrderDetails"] = orderDetail.GetItemDetails(_context); ViewData["OrderName"] = orderDetail.order.Name; ViewData["OrderNumber"] = orderDetail.order.Id; ViewData["OrderDate"] = orderDetail.order.dateTime; return(View("ViewOrderList")); } //Add modelstate error here. ModelState.AddModelError(string.Empty, "Details do not match any order."); } return(View()); } }