コード例 #1
0
        public ActionResult Index()
        {
            ServiceCart cart = serviceCart.GetCart(this.HttpContext);

            ViewBag.Total = cart.GetTotalFromCart();
            return(View());
        }
コード例 #2
0
        public ActionResult Index(OrderViewModel model)
        {
            OrderDTO orderDTO = new OrderDTO();

            TryUpdateModel(orderDTO);
            if (ModelState.IsValid)
            {
                ServiceCart cart = serviceCart.GetCart(this.HttpContext);

                orderDTO.OrderDate = DateTime.Now;
                orderDTO.Total     = cart.GetTotalFromCart();
                orderDTO.Username  = User.Identity.Name;


                serviceOrder.CreateOrder(orderDTO);
                cart.GetCreateOrder(orderDTO);


                return(RedirectToAction("index", "home"));
            }
            else
            {
                ViewBag.Error = "Error";
                ModelState.AddModelError("", "Not correct datas!");
                return(View(model));
            }
        }
コード例 #3
0
        public ActionResult DisplayCart(string returnUrl)
        {
            ServiceCart           cart  = serviceCart.GetCart(this.HttpContext);
            ShoppingCartViewModel model = new ShoppingCartViewModel
            {
                CartItems = cart.GetItemsCart(),
                CartTotal = cart.GetTotalFromCart(),
                returnUrl = returnUrl
            };

            return(View(model));
        }