Пример #1
0
        public async Task <IActionResult> Categories()
        {
            var catTuples = await _shopManager.GetAllCategoriesWithProductCountAsync();

            var cats = new List <CategoryDto>();

            foreach (var catTuple in catTuples)
            {
                var catDto = _mapper.Map <CategoryDto>(catTuple.Item1);
                catDto.ProductCount = catTuple.Item2;
                cats.Add(catDto);
            }

            return(View(cats.ToTree().OrderBy(x => x.Name)));
        }