Пример #1
0
        public IActionResult ProductInfo(int ProductId)
        {
            HttpContext.Session.SetInt32("CurrentProductId", ProductId);

            Product RetrievedProduct = dbContext.Products
                                       .Include(p => p.Category)
                                       .ThenInclude(sub => sub.Category)
                                       .FirstOrDefault(p => p.ProductId == ProductId);

            List <Category> AllCategories = dbContext.Categories
                                            .Where(c => !RetrievedProduct.Category.Any(a => a.CategoryId == c.CategoryId))
                                            .ToList();

            ProductCategoryWraper DataToPost = new ProductCategoryWraper()
            {
                Product    = RetrievedProduct,
                Categories = AllCategories
            };

            return(View(DataToPost));
        }
Пример #2
0
        public IActionResult CategoryInfo(int CategoryId)
        {
            HttpContext.Session.SetInt32("CurrentCategoryId", CategoryId);

            Category RetrievedCategory = dbContext.Categories
                                         .Include(p => p.Products)
                                         .ThenInclude(sub => sub.Product)
                                         .FirstOrDefault(p => p.CategoryId == CategoryId);

            List <Product> AllProducts = dbContext.Products
                                         .Where(c => !RetrievedCategory.Products.Any(a => a.ProductId == c.ProductId))
                                         .ToList();

            ProductCategoryWraper DataToPost = new ProductCategoryWraper()
            {
                Category = RetrievedCategory,
                Products = AllProducts
            };

            return(View(DataToPost));
        }