Exemple #1
0
        //
        // 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);
        }
Exemple #2
0
        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;
        }
Exemple #3
0
 public CustomerInfo(OrderModel orderModel)
     : this(orderModel.CustomerName, orderModel.Email, orderModel.Phone, orderModel.Address)
 {
 }
Exemple #4
0
 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));
 }
Exemple #6
0
 public void AddOrder(OrderModel order)
 {
     context.Orders.Add(order);
     context.SaveChanges();
 }