Publish post
This commit is contained in:
parent
cfcef8b77d
commit
2a642faecd
2 changed files with 36 additions and 0 deletions
|
@ -103,5 +103,19 @@ namespace Robware.Api.Blog.Controllers {
|
|||
await _blogRepository.DeletePostAsync(id);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost(nameof(PublishPost))]
|
||||
public async Task<ActionResult> PublishPost([FromBody] int id) {
|
||||
try {
|
||||
var post = await _blogRepository.GetPostByIdAsync(id);
|
||||
post.Publish();
|
||||
await _blogRepository.SavePost(post);
|
||||
return Ok();
|
||||
}
|
||||
catch (ItemNotFoundException e) {
|
||||
_logger.Log(LogLevel.Error, e.Message);
|
||||
return BadRequest("Tried to publish post that doesn't exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue