public async Task <IActionResult> AssignCategory(List <AssignCategoryModel> list) { TempData["active"] = "blog"; int id = (int)TempData["blogid"]; foreach (var item in list) { if (item.Exits) { CategoryBlogModel model = new CategoryBlogModel(); model.BlogId = id; model.CategoryId = item.CategoryId; await _blogApiService.AddToCategory(model); } else { CategoryBlogModel model = new CategoryBlogModel(); model.BlogId = id; model.CategoryId = item.CategoryId; await _blogApiService.RemoveFromCategory(model); } } return(RedirectToAction(nameof(Index))); }