예제 #1
0
        public ActionResult ConfirmOrder(string quan1 = "-1",
                                         string quan2 = "-1", string quan3 = "-1", string quan4 = "-1", string total = "0")
        {
            SaveOrderLocal(quan1, quan2, quan3, quan4, total);
            OrderDomainModel orderDomain = new OrderDomainModel();
            int        orderId           = orderDomain.SaveOrder(cartModel, User.Identity.Name);
            OrderModel orderModel        = orderDomain.GetUserOrder(orderId);

            cartModel            = null;
            Session["CartModel"] = null;
            return(View("ConfirmOrder", orderModel));
        }
예제 #2
0
        public ViewResult Checkout(CartDomainModel cart, Order order)
        {
            if (cart.GetCartLines.Count() == 0)
            {
                ModelState.AddModelError("", "Sorry, your cart is empty!");
            }
            if (ModelState.IsValid)
            {
                OrderDomainModel od = new OrderDomainModel();
                order.ID             = Guid.NewGuid();
                order.Status         = 0;
                order.CreateDatetime = DateTime.Now.ToUniversalTime();
                order.UpdateDatetime = DateTime.Now.ToUniversalTime();
                order.OrderItems     = new List <OrderItem>();

                IEnumerable <CartLine> cartLines = cart.GetCartLines;

                foreach (CartLine ca in cartLines)
                {
                    OrderItem oi = new OrderItem();
                    oi.ID = Guid.NewGuid();
                    //oi.OrderID = order.ID;
                    oi.ProductID      = ca.Product.ID;
                    oi.Price          = ca.Product.Price;
                    oi.Quantity       = ca.Quantity;
                    oi.Status         = 0;
                    oi.CreateDatetime = DateTime.Now.ToUniversalTime();
                    oi.UpdateDatetime = DateTime.Now.ToUniversalTime();
                    order.OrderItems.Add(oi);
                }

                od.SaveOrder(order);
                cart.Clear();
                return(View("Completed"));
            }
            else
            {
                return(View(order));
            }


            return(View());
        }