public async Task <IActionResult> AssignCategory(int id, [FromServices] ICategoryApiService categoryApiService) { TempData["active"] = "blog"; var categories = await categoryApiService.GetAllAsync(); var blogCategories = await _blogApiService.GetCategories(id); TempData["blogId"] = id; List <AssignCategoryModel> list = new List <AssignCategoryModel>(); foreach (var category in categories) { AssignCategoryModel model = new AssignCategoryModel(); model.CategoryId = category.Id; model.CategoryName = category.Name; model.Exists = blogCategories.Contains(category); list.Add(model); } return(View(list)); }