Beispiel #1
0
        public async Task RemoveFromCategoryAsync(CategoryBlogDTO categoryBlogDTO)
        {
            var categoryBlog = await _categoryBlogDAL.GetAsync(x =>
                                                               x.BlogId == categoryBlogDTO.BlogId &&
                                                               x.CategoryId == categoryBlogDTO.CategoryId);

            if (categoryBlog != null)
            {
                await _categoryBlogDAL.RemoveAsync(categoryBlog);
            }
        }
Beispiel #2
0
        public async Task AddToCategoryAsync(CategoryBlogDTO categoryBlogDTO)
        {
            var categoryBlog = await _categoryBlogDAL.GetAsync(x =>
                                                               x.BlogId == categoryBlogDTO.BlogId &&
                                                               x.CategoryId == categoryBlogDTO.CategoryId);

            if (categoryBlog == null)
            {
                await _categoryBlogDAL.AddAsync(
                    new CategoryBlog
                {
                    BlogId     = categoryBlogDTO.BlogId,
                    CategoryId = categoryBlogDTO.CategoryId
                });
            }
        }
Beispiel #3
0
        public async Task <IActionResult> RemoveFromCategory([FromQuery] CategoryBlogDTO categoryBlogDTO)
        {
            await _blogService.RemoveFromCategoryAsync(categoryBlogDTO);

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> AddToCategory(CategoryBlogDTO categoryBlogDTO)
        {
            await _blogService.AddToCategoryAsync(categoryBlogDTO);

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