// // GET: /Order/ public ActionResult Index() { OrderModel orderModel = new OrderModel(); var dict = new Dictionary<int, OrderedItemModel>(); if (Session[Constants.SESSION_BASKET] is Dictionary<int, OrderedItemModel>) dict = Session[Constants.SESSION_BASKET] as Dictionary<int, OrderedItemModel>; foreach (var item in dict) { orderModel.OrderedItems.Add(item.Value); } return View(orderModel); }
public static OrderModel ToOrderModel(this Order order) { var res = new OrderModel { Email = order.Email, Address = order.Address, Phone = order.Phone, CustomerName = order.CustomerName, Id=order.Id }; foreach (var it in order.UnitOrderRelations.Select(r => r.ToOrderedItemModel())) { res.OrderedItems.Add(it); } return res; }
public CustomerInfo(OrderModel orderModel) : this(orderModel.CustomerName, orderModel.Email, orderModel.Phone, orderModel.Address) { }
public ActionResult SubmitOrder(OrderModel order) { DisplayModelsProvider.SaveOrder(order); Session[Constants.SESSION_BASKET] = null; return RedirectToAction("Index","Home"); }
public void SaveOrder(OrderModel order) { dataProvider.CreateOrder( order.OrderedItems.Select(o => new UnitOrderRelation { UnitId = o.UnitId, Quantity = o.Quantity }), new CustomerInfo(order)); }
public void AddOrder(OrderModel order) { context.Orders.Add(order); context.SaveChanges(); }