Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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
                });
            }
        }
Beispiel #3
0
        public async Task <IActionResult> RemoveFromCategory([FromQuery] CategoryTopicDto categoryTopicDto)
        {
            await _topicService.RemoveFromCategoryAsync(categoryTopicDto);

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> AddToCategory(CategoryTopicDto categoryTopicDto)
        {
            await _topicService.AddToCategoryAsync(categoryTopicDto);

            return(Created("", categoryTopicDto));
        }