public async Task <IActionResult> AssignCategory(int id, [FromServices] ICategoryApiService categoryApiService) { TempData["active"] = "blog"; var categories = await categoryApiService.GetAllCategoriesAsync(); var blogCategory = (await _blogApiService.GetAllCategories(id)).Select(i => i.Name).ToList(); TempData["blogid"] = id; List <AssignCategoryModel> models = new List <AssignCategoryModel>(); foreach (var category in categories) { AssignCategoryModel model2 = new AssignCategoryModel(); model2.CategoryId = category.Id; model2.CategoryName = category.Name; model2.Exits = blogCategory.Contains(category.Name); models.Add(model2); } return(View(models)); }
// GET: Categories public async Task <IActionResult> Index() { TempData["active"] = "category"; return(View(await _categoryApiService.GetAllCategoriesAsync())); }