public IActionResult All(ProductsAllViewModelWrapper model)
        {
            var categoryId = model.DisplayCategory;
            var category   = this._categoriesService.GetCategory(categoryId);

            var products = this._productsService.GetAllProductsByCategory(category.Name.ToString())
                           .To <ProductsAllViewModel>()
                           .ToList();

            var productsCategories = this._productsService.GetAllCategories()
                                     .Select(t => new SelectListItem()
            {
                Value = t.Id,
                Text  = t.Name.ToString()
            });

            this.ViewData["ProductsCategories"] = productsCategories;

            var dto = new ProductsAllViewModelWrapper()
            {
                DisplayCategory = category.Name.ToString(),
                Products        = products
            };

            return(View(dto));
        }
Esempio n. 2
0
        public IActionResult All(ProductsAllViewModelWrapper model)
        {
            var categoryId = model.DisplayCategory;
            var category   = this._categoriesService.GetCategory(categoryId);

            var products = this._productsService.GetAllProductsByCategory(category.Name.ToString())
                           .Select(p => new ProductsAllViewModel()
            {
                Description = p.Description,
                Name        = p.Name,
                Id          = p.Id,
                Price       = p.Price.ToString(),
                ImageUrl    = p.ImageUrl
            }).ToList();

            var dto = new ProductsAllViewModelWrapper()
            {
                Products        = products,
                DisplayCategory = category.Name.ToString()
            };

            var categories = this._categoriesService.GetAllCategories()
                             .Select(p => new SelectListItem()
            {
                Value = p.Id,
                Text  = p.Name.ToString()
            });

            this.ViewData["ProductCategories"] = categories;
            return(View(dto));
        }
        public IActionResult All()
        {
            var products = this._productsService.All()
                           .To <ProductsAllViewModel>()
                           .ToList();

            var dto = new ProductsAllViewModelWrapper()
            {
                Products        = products,
                DisplayCategory = "All"
            };

            var productsCategories = this._productsService.GetAllCategories()
                                     .Select(t => new SelectListItem()
            {
                Value = t.Id,
                Text  = t.Name.ToString()
            });

            this.ViewData["ProductsCategories"] = productsCategories;

            return(View(dto));
        }
Esempio n. 4
0
        public IActionResult All()
        {
            var products = this._productsService.All()
                           .Select(p => new ProductsAllViewModel()
            {
                Description = p.Description,
                Name        = p.Name,
                Id          = p.Id,
                Price       = p.Price.ToString(),
                ImageUrl    = p.ImageUrl
            }).ToList();

            var dto = new ProductsAllViewModelWrapper()
            {
                Products            = products,
                DisplayCategory     = "All",
                DisplayDefaultTable = "Select your table"
            };

            var productsCategories = this._categoriesService.GetAllCategories()
                                     .Select(p => new SelectListItem()
            {
                Value = p.Id,
                Text  = p.Name.ToString()
            });

            var availableTables = this._tablesService.AllTables()
                                  .Select(t => new SelectListItem()
            {
                Value = t.Id, Text = t.Name
            });

            this.ViewData["ProductCategories"] = productsCategories;
            this.ViewData["AvailableTables"]   = availableTables;
            return(View(dto));
        }