示例#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();
            }
        }
示例#2
0
        public async Task <IActionResult> GetAllCategoriesAsync()
        {
            var command = new GetAllCategories();
            var result  = await _mediator.Send(command);

            return(Ok(result));
        }
示例#3
0
        public async Task <IActionResult> Get()
        {
            var command = new GetAllCategories();

            await DispatchAsync(command);

            return(Ok(Json(command.categories)));
        }
        public async Task <PagedList <GetAllCategoriesDto> > Handle(GetAllCategories request, CancellationToken cancellationToken)
        {
            var resources = await _resourceRepository.Categories.AsNoTracking().ToListAsync(cancellationToken);

            var result = resources.Select(GetAllCategoriesDto.Create);

            return(PagedList <GetAllCategoriesDto> .Create(result));
        }
 public void OnGet()
 {
     ShoppingCart = LoadCart();
     CartItems    = new GetCartItems(_context).Do(ShoppingCart.CartId);
     Products     = new GetAllProducts(_context).Do(0)
                    .Where(prod => CartItems.Select(cartItem => cartItem.ProductRefId)
                           .Contains(prod.ProductId));
     Categ = new GetAllCategories(_context).Do();
 }
        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);
        }
示例#7
0
 public void OnPost(string ProductName)
 {
     ShoppingCartId = LoadCart().Result.CartId;
     if (ProductName != null)
     {
         Products = new GetAllProducts(_context).Do().Where(prod => prod.Name.ToLower().Contains(ProductName.ToLower()));
     }
     else
     {
         Products = new GetAllProducts(_context).Do();
     }
     Categ = new GetAllCategories(_context).Do();
 }
示例#8
0
 public void OnGet()
 {
     ShoppingCartId = LoadCart().Result.CartId;
     Products       = new GetAllProducts(_context).Do();
     Categ          = new GetAllCategories(_context).Do();
 }
 public void OnGet(string productName)
 {
     ShoppingCartId = LoadCart().CartId;
     Products       = new GetProduct(_context).Do(productName);
     Categ          = new GetAllCategories(_context).Do();
 }
示例#10
0
 public async Task <IEnumerable <Category> > GetAll(GetAllCategories query)
 => await this.QueryAsync(query);
示例#11
0
 public async Task <IEnumerable <Category> > HandleAsync(GetAllCategories query)
 => await mongoRepository.FindAsync(_ => true);
示例#12
0
        public async Task <IEnumerable <CategoryDTO> > Handle(GetAllCategories request)
        {
            var categories = await _context.Categories.ToListAsync();

            return(categories.Select(c => _mapper.MapCategoryToDTO(c)));
        }