// GET: Order/Call public ActionResult Call() { var orderIDs = new List <int>(TempData["OrderIDs"] as int[] ?? new int[] { }); try { ICollection <LibI.IOrder> lOrders = orderIDs.Select(i => s_libHelper.Orders.First(o => o.ID == i)).ToList(); LibI.IOrder first = lOrders.First(); ICollection <LibI.IOrder> rejected = first.Location.Order(first.User, lOrders); orderIDs = lOrders.Select(o => o.ID).Where(i => rejected.Any(ro => ro.ID == i)).ToList(); } catch { // some malformed order calls just throw exception return(RedirectToAction("Failure")); } finally { TempData["OrderIDs"] = orderIDs.ToArray <int>(); } s_libHelper.Reload(); int userID = (int)TempData["UserID"]; if (orderIDs.Count == 0) { return(RedirectToAction("Success")); } return(RedirectToAction(nameof(Index), new { id = userID })); }
// GET: Order/Details/5 public ActionResult Details(int id) { LibI.IOrder lO = s_libHelper.Orders.First(o => o.ID == id); Location l = new Location(lO.Location); Order order = new Order(lO, l, new User(lO.User, new Location(lO.User.DefaultLocation))); ViewBag.OrderParts = lO.PizzasByPrice; return(View(order)); }
public Order(LibI.IOrder lib, Location location, User user) { Lib = lib; if (location.Lib.ID != Lib.Location.ID) { throw new InvalidOperationException("location inconsistent between model and library."); } Location = location; if (user.Lib.AccountID != Lib.User.AccountID) { throw new InvalidOperationException("user inconsistent between model and library."); } User = user; _time = lib.Time; PizzasByPrice = lib.PizzasByPrice; ID = lib.ID; }