예제 #1
0
        public async Task <IActionResult> ModifyBlogAsync(int id, [FromBody] Domain.Blogs.Models.ModifyPost model)
        {
            if (string.IsNullOrWhiteSpace(model.Title))
            {
                return(BadRequest("标题不能为空"));
            }
            if (model.Targets.Length == 0)
            {
                return(BadRequest("标签不能为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Content))
            {
                return(BadRequest("内容不能为空"));
            }

            BlogsManager manager = new BlogsManager();
            var          blog    = await manager.GetBlogAsync(id);

            if (blog is null)
            {
                return(NotFound());
            }
            await blog.ModifyAsync(model);

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> GetBlogDetailAsync(int id, bool readed)
        {
            BlogsManager blogsManager = new BlogsManager();
            var          blog         = await blogsManager.GetBlogAsync(id);

            if (blog is null)
            {
                return(NotFound());
            }
            Domain.Blogs.Results.BlogDetail detail = await blog.GetDetailAsync(readed);

            return(Ok(detail));
        }
예제 #3
0
        public async Task <IActionResult> LikeAsync(int id)
        {
            BlogsManager manager = new BlogsManager();
            var          blog    = await manager.GetBlogAsync(id);

            if (blog is null)
            {
                return(NotFound());
            }
            await blog.LikeAsync();

            return(NoContent());
        }