public async Task <IActionResult> AssignCategory(List <AssignCategoryModel> list) { TempData["Active"] = ActivePage.Blog; int id = (int)TempData["blogId"]; foreach (var item in list) { if (item.Exists) { var model = new CategoryBlogDto { BlogId = id, CategoryId = item.CategoryId }; await _blogService.AddToCategoryAsync(model); } else { var model = new CategoryBlogDto { BlogId = id, CategoryId = item.CategoryId }; await _blogService.RemoveFromCategoryAsync(model); } } return(RedirectToAction("Index")); }
public async Task RemoveFromCategoryAsync(CategoryBlogDto categoryBlogDto) { var deletedCategory = await _categoryDal.GetAsync(I => I.CategoryId == categoryBlogDto.CategoryId && I.BlogId == categoryBlogDto.BlogId); if (deletedCategory != null) { await _categoryDal.RemoveAsync(deletedCategory); } }
public async Task AddToCategoryAsync(CategoryBlogDto categoryBlogDto) { var control = await _categoryDal.GetAsync(I => I.BlogId == categoryBlogDto.BlogId && I.CategoryId == categoryBlogDto.CategoryId); if (control == null) { await _categoryDal.AddAsync(new CategoryBlog { BlogId = categoryBlogDto.BlogId, CategoryId = categoryBlogDto.CategoryId }); } }
public async Task RemoveToCategoryAsync(CategoryBlogDto categoryBlogDto) { var deletedCategoryBlog = await _categoryBlogService.GetAsync(I => I.CategoryId == categoryBlogDto.CategoryId && I.BlogId == categoryBlogDto.ArticleId); if (deletedCategoryBlog != null) { await _categoryBlogService.RemoveAsync(deletedCategoryBlog); } }
public async Task RemoveFromCategoryAsync(CategoryBlogDto categoryBlogDto) { var categoryBlog = await _categoryBlogService.GetAsync(p => p.CategoryId == categoryBlogDto.CategoryId && p.BlogId == categoryBlogDto.BlogId); if (categoryBlog != null) { await _categoryBlogService.RemoveAsync(categoryBlog); } }
public async Task AddToCategoryAsync(CategoryBlogDto categoryBlogDto) { var addToCategory = await _categoryBlogDal.GetAsync(i => i.BlogId == categoryBlogDto.BlogId && i.CategoryId == categoryBlogDto.CategoryId); if (addToCategory == null) { await _categoryBlogDal.AddAsync(new CategoryBlog { BlogId = categoryBlogDto.BlogId, CategoryId = categoryBlogDto.CategoryId }); } }
public async Task AddToCategoryAsync(CategoryBlogDto categoryBlogDto) { var control = await _categoryBlogDal.GetAsync(x => x.CategoryId == categoryBlogDto.CategoryId && x.BlogId == categoryBlogDto.BlogId); if (control == null) { await _categoryBlogDal.InsertAsync(new CategoryBlog { BlogId = categoryBlogDto.BlogId, CategoryId = categoryBlogDto.CategoryId }); } }
public async Task AddToCategoryAsync(CategoryBlogDto categoryBlogDto) { var control = await _categoryBlogService.GetAsync(p => p.CategoryId == categoryBlogDto.CategoryId && p.BlogId == categoryBlogDto.BlogId); if (control == null) { await _categoryBlogService.AddAsync( new CategoryBlog { BlogId = categoryBlogDto.BlogId, CategoryId = categoryBlogDto.CategoryId } ); } }
public async Task <IActionResult> RemoveFromCategory([FromQuery] CategoryBlogDto categoryBlogDto) { await _blogService.RemoveFromCategoryAsync(categoryBlogDto); return(NoContent()); }
public async Task <IActionResult> AddToCategory(CategoryBlogDto categoryBlogDto) { await _blogService.AddToCategoryAsync(categoryBlogDto); return(Created("", categoryBlogDto)); }
public async Task <IActionResult> RemoveFromCategory(CategoryBlogDto model) { await _blogService.RemoveFromCategoryAsync(model); return(NoContent()); }
public async Task <IActionResult> AddToCategory(CategoryBlogDto model) { await _blogService.AddToCategoryAsync(model); return(Created("", model)); }