public IActionResult GetCategory(int type) { var items = new List <CategoryViewModel>(); if (type == (int)MenuType.Blog) { var blogCategories = _blogCategoryService.GetAllFlat(); foreach (var blCategory in blogCategories) { var categoryViewModel = new CategoryViewModel() { Id = blCategory.Id, Name = blCategory.Name, SortOrder = blCategory.SortOrder, ParentId = blCategory.ParentId }; items.Add(categoryViewModel); } } else if (type == (int)MenuType.Product) { var productCategories = _productCategoryService.GetAllFlat(); foreach (var pCate in productCategories) { var categoryViewModel = new CategoryViewModel() { Id = pCate.Id, Name = pCate.Name, SortOrder = pCate.SortOrder, ParentId = pCate.ParentId }; items.Add(categoryViewModel); } } return(new ObjectResult(items)); }