public ShoppingCartVM PutInShoppingCard(ShoppingCartVM shoppingCart, OrderPositionVM orderPosition)
        {
            if (orderPosition.Count <= 0)
            {
                return(shoppingCart);
            }
            if (shoppingCart.Products.IsNullOrEmpty())
            {
                shoppingCart.Products = new List <OrderPositionVM>();
            }

            var orderedPizza = shoppingCart.Products
                               .FirstOrDefault(x => x.Pizza.Id == orderPosition.Pizza.Id);

            if (orderedPizza == null)
            {
                var products = shoppingCart.Products.ToList();
                products.Add(orderPosition);
                shoppingCart.Products = products;
            }
            else
            {
                orderedPizza.Count += orderPosition.Count;
            }

            return(shoppingCart);
        }
 public static OrderPosition ToOrderPosition(this OrderPositionVM orderPosition)
 {
     return(new OrderPosition
     {
         Pizza = orderPosition.Pizza.ToPizza(),
         Count = orderPosition.Count
     });
 }
示例#3
0
        public JsonResult DelOrderInOrderNewAjax([FromBody] OrderPositionVM orderPosition)
        {
            var operatorId = HttpContext.User.GetId();

            _pesonalPageVmService.SetOrderCancell(orderPosition, operatorId);

            return(Json(new { IsSuccess = true }));
        }
示例#4
0
        public JsonResult AddToShoppingCardAjax([FromBody] OrderPositionVM orderPosition)
        {
            var shoppingCart = HttpContext.Session.Get <ShoppingCartVM>(SessionKeys.ShoppingCart);

            shoppingCart = _shoppingCardVmService.PutInShoppingCard(shoppingCart, orderPosition);
            HttpContext.Session.Set(SessionKeys.ShoppingCart, shoppingCart);

            return(Json(new { IsSuccess = true }));
        }
示例#5
0
        public IActionResult AddToShoppingCard(OrderPositionVM orderPosition)
        {
            var shoppingCart = HttpContext.Session.Get <ShoppingCartVM>(SessionKeys.ShoppingCart);

            shoppingCart = _shoppingCardVmService.PutInShoppingCard(shoppingCart, orderPosition);
            HttpContext.Session.Set(SessionKeys.ShoppingCart, shoppingCart);

            return(RedirectToAction("Index"));
        }
 public ShoppingCartVM DeleteFromShoppingCard(ShoppingCartVM shoppingCart, OrderPositionVM orderPosition)
 {
     shoppingCart.Products.RemoveAll(x => x.Pizza.Id == orderPosition.Pizza.Id);
     return(shoppingCart);
 }
示例#7
0
        public JsonResult ExecuteOrderInOrderToDeliveryAjax([FromBody] OrderPositionVM orderPosition)
        {
            _pesonalPageVmService.SetOrderDelivered(orderPosition);

            return(Json(new { IsSuccess = true }));
        }
 public void SetOrderDelivered(OrderPositionVM orderPosition)
 {
     _orderService.SetOrderState(orderPosition.Pizza.Id, OrderState.Paid);
 }
 public void SetOrderCancell(OrderPositionVM orderPosition, Guid operatorId)
 {
     _orderService.SetOrderCancelledStateByOperator(orderPosition.Pizza.Id, operatorId);
 }