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();
            }
        }
 public void OnGet(int orderId)
 {
     OrderInfo       = new GetOrderInfo(_context).Do(orderId);
     ProductInOrders = new GetAllProductInOrder(_context).Do(orderId);
     Products        = new GetAllProducts(_context).Do()
                       .Where(prod => ProductInOrders.Select(product => product.ProductRefId).Contains(prod.ProductId));
 }
Beispiel #3
0
        public async Task <IActionResult> OnPost()
        {
            var currUser = _userManager.GetUserId(User);

            Order = new GetOrder(_context).Do(currUser, "Pending");
            var orderInfo = new GetOrderInfo(_context).Do(Order.OrderId);

            if (orderInfo == null)
            {
                await new CreateOrderInfo(_context).Do(new OrderInfosViewModel
                {
                    FirstName  = OrderInfos.FirstName,
                    LastName   = OrderInfos.LastName,
                    Address    = OrderInfos.Address,
                    PhoneNo    = OrderInfos.PhoneNo,
                    OrderRefId = Order.OrderId,
                });
            }
            else
            {
                await new UpdateOrderInfo(_context).Do(new OrderInfosViewModel
                {
                    OrderInfoId = orderInfo.OrderInfoId,
                    FirstName   = OrderInfos.FirstName,
                    LastName    = OrderInfos.LastName,
                    Address     = OrderInfos.Address,
                    PhoneNo     = OrderInfos.PhoneNo,
                    OrderRefId  = Order.OrderId,
                });
            }
            return(RedirectToPage("/LastCheck"));
        }
Beispiel #4
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));
        }
        public void OnGet()
        {
            var currUser = _userManager.GetUserId(User);

            ShoppingCart = new GetShoppingCart(_context).Do(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");
            OrderInfos = new GetOrderInfo(_context).Do(Order.OrderId);
        }