public async Task <CategoryTreeResponce> GetTreeCategoryAsync() { CategoryTreeResponce resultTree = new CategoryTreeResponce(); var allCategories = await m_db.Categories.Include(x => (x as CategoryNodeDbModel).ChildCategories).ToListAsync(); m_db.ChangeTracker.LazyLoadingEnabled = false; // фикс lazy-loading запросов IEnumerable <CategoryDbModel> rootCategories = allCategories.Where(x => x.ParentId == null); var mappedRootCat = rootCategories.Select(x => m_mapper.Map <CategoryTreeElementResponce>(x)).ToList(); resultTree.RootCategories = mappedRootCat; return(resultTree); }
public async Task <IActionResult> GetTreeCategoriesAsync() { CategoryTreeResponce result = await m_categoriesAPIService.GetTreeCategoryAsync(); return(Ok(result)); }