Esempio n. 1
0
        // GET: CatalogItems
        public async Task <IActionResult> Index(int id)
        {
            Catalog catalog = await _catalogService.DetailsAsync(id);

            var products = await _productService.GetProductsAsync();

            var catalogItems = await _catalogItemsService.GetCatalogItemsAsync();

            var checkedItems = new List <int>();

            foreach (CatalogItems item in catalogItems)
            {
                if (item.CatalogId == id)
                {
                    checkedItems.Add(item.ProductId);
                }
            }
            var filteredProducts = products.Where(e => checkedItems.Contains(e.Id));

            ViewBag.CatalogId   = id;
            ViewBag.Selected    = filteredProducts;
            ViewBag.CatalogName = catalog.CatalogName;
            return(View(products));
        }