示例#1
0
        public JsonResult ProcessOrder()
        {
            var order = SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Get();

            _orderService.ProcessOrder(order);
            SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Reset();
            return(Json(new { success = true }));
        }
示例#2
0
        /// <summary>
        /// Landing Page
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            //Hack for product repository. Rather than persisting to DB, we persist into session.
            ViewBag.Order = SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Get();
            var viewModel = new OrderIndexViewModel(_productRepository.All());

            return(View(viewModel));
        }
示例#3
0
        /// <summary>
        /// Landing Page
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            //Hack for product repository. Rather than persisting to DB, we persist into session.
            var pendingOrders = SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Get();

            ViewBag.Order = pendingOrders;
            var currentCustomerOrders = _orderService.GetProcessedCustomerOrders(CurrentUser);
            var viewModel             = new MyOrderIndexViewModel(currentCustomerOrders, pendingOrders);

            return(View(viewModel));
        }
示例#4
0
        private bool _removeOrderItem(int productId)
        {
            var productOrdered       = _productRepository.Get(productId);
            var customerCurrentOrder = SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Get();
            var currentOrderItem     = customerCurrentOrder.GetOrderItemForProductOrdered(productId);

            // Check if there's an order
            if (currentOrderItem == null)
            {
                return(false);
            }

            // Add the product
            customerCurrentOrder.RemoveProduct(productOrdered, 1);
            SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Set(customerCurrentOrder);
            return(true);
        }
示例#5
0
        private bool _addOrderItem(int productId)
        {
            var productOrdered       = _productRepository.Get(productId);
            var customerCurrentOrder = SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Get();
            var currentOrderItem     = customerCurrentOrder.GetOrderItemForProductOrdered(productId);

            // Check for enough stock.
            if (currentOrderItem != null)
            {
                if ((currentOrderItem.QtyOrdered + 1) > productOrdered.StockQuantity)
                {
                    return(false);
                }
            }
            if (!(productOrdered.StockQuantity > 0))
            {
                return(false);
            }

            // Add the product
            customerCurrentOrder.AddProduct(productOrdered, 1);
            SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Set(customerCurrentOrder);
            return(true);
        }
示例#6
0
 public JsonResult ClearOrder()
 {
     SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Reset();
     return(Json(new { success = true }));
 }