public async Task RemoveFromCategoryAsync(CategoryTopicDto categoryTopicDto) { var deletedCategoryTopic = await _categoryTopicService.GetAsync (x => x.CategoryId == categoryTopicDto.CategoryId && x.TopicId == categoryTopicDto.TopicId); if (deletedCategoryTopic != null) { await _categoryTopicService.RemoveAsync(deletedCategoryTopic); } }
public async Task AddToCategoryAsync(CategoryTopicDto categoryTopicDto) { var controlAddCategory = await _categoryTopicService.GetAsync (x => x.CategoryId == categoryTopicDto.CategoryId && x.TopicId == categoryTopicDto.TopicId); if (controlAddCategory == null) { await _categoryTopicService.AddAsync(new CategoryTopic { TopicId = categoryTopicDto.TopicId, CategoryId = categoryTopicDto.CategoryId }); } }
public async Task <IActionResult> RemoveFromCategory([FromQuery] CategoryTopicDto categoryTopicDto) { await _topicService.RemoveFromCategoryAsync(categoryTopicDto); return(NoContent()); }
public async Task <IActionResult> AddToCategory(CategoryTopicDto categoryTopicDto) { await _topicService.AddToCategoryAsync(categoryTopicDto); return(Created("", categoryTopicDto)); }