public JsonResult ProcessOrder() { var order = SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Get(); _orderService.ProcessOrder(order); SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Reset(); return(Json(new { success = true })); }
/// <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)); }
/// <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)); }
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); }
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); }
public JsonResult ClearOrder() { SessionFacade.CurrentCustomerOrder(HttpContext, CurrentUser).Reset(); return(Json(new { success = true })); }