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

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

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