Beispiel #1
0
        public async Task OnGet()
        {
            var currUser = _userManager.GetUserId(User);

            ShoppingCart = await LoadCart(currUser);

            CartItems = new GetCartItems(_context).Do(ShoppingCart.CartId);
            Products  = new GetAllProducts(_context).Do()
                        .Where(prod => CartItems.Select(cartItem => cartItem.ProductRefId)
                               .Contains(prod.ProductId));
            Categ = new GetAllCategories(_context).Do();
            Order = new GetOrder(_context).Do(currUser, "Pending");
            if (Order == null)
            {
                await new CreateOrder(_context).Do(new OrderViewModel
                {
                    Status       = "Pending",
                    CustomerId   = currUser,
                    TotalOrdered = ShoppingCart.TotalInCart,
                });
                Order = new GetOrder(_context).Do(currUser, "Pending");
            }
            OrderInfos = new GetOrderInfo(_context).Do(Order.OrderId);
            if (OrderInfos == null)
            {
                OrderInfos = new OrderInfosViewModel();
            }
        }
Beispiel #2
0
        public async Task <IActionResult> GetOrderInfo(string customerId)
        {
            var currUser = customerId;

            if (currUser == "undefined")
            {
                currUser = _httpContextAccessor.HttpContext.Request.Cookies["anonymousUsr"];
            }
            var Order = new GetOrder(_context).Do(currUser, "Pending");

            if (Order == null)
            {
                await new CreateOrder(_context).Do(new OrderViewModel
                {
                    Status     = "Pending",
                    CustomerId = currUser
                });
                Order = new GetOrder(_context).Do(currUser, "Pending");
            }
            var OrderInfos = new GetOrderInfo(_context).Do(Order.OrderId);

            if (OrderInfos == null)
            {
                OrderInfos = new OrderInfosViewModel {
                    OrderRefId = Order.OrderId
                }
            }
            ;
            return(Ok(OrderInfos));
        }
Beispiel #3
0
 public async Task <IActionResult> UpdateOrderInfo([FromForm] OrderInfosViewModel vm)
 {
     if (ModelState.IsValid)
     {
         await new UpdateOrderInfo(_context).Do(vm);
         return(Ok());
     }
     return(BadRequest());
 }