aboutsummaryrefslogtreecommitdiff
path: root/src/Web/DevHive.Web/Controllers/PostController.cs
diff options
context:
space:
mode:
authorVictor S <57849063+transtrike@users.noreply.github.com>2021-03-13 11:47:26 +0200
committerGitHub <noreply@github.com>2021-03-13 11:47:26 +0200
commit4add0831649f6e534d3883aa0e0e7f380d8042c7 (patch)
tree9647a722d5974337f999da34b9a023114b0a9324 /src/Web/DevHive.Web/Controllers/PostController.cs
parent02cf05d6cc38e6907404f65976440b811d6cc60a (diff)
parent93ded2b68a31fc9da643ac65955219e4f306ab82 (diff)
downloadDevHive-4add0831649f6e534d3883aa0e0e7f380d8042c7.tar
DevHive-4add0831649f6e534d3883aa0e0e7f380d8042c7.tar.gz
DevHive-4add0831649f6e534d3883aa0e0e7f380d8042c7.zip
Merge pull request #20 from Team-Kaleidoscope/nswag
XML Documentation on Controllers
Diffstat (limited to 'src/Web/DevHive.Web/Controllers/PostController.cs')
-rw-r--r--src/Web/DevHive.Web/Controllers/PostController.cs34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/Web/DevHive.Web/Controllers/PostController.cs b/src/Web/DevHive.Web/Controllers/PostController.cs
index 309070c..44b291d 100644
--- a/src/Web/DevHive.Web/Controllers/PostController.cs
+++ b/src/Web/DevHive.Web/Controllers/PostController.cs
@@ -10,6 +10,9 @@ using DevHive.Common.Jwt.Interfaces;
namespace DevHive.Web.Controllers
{
+ /// <summary>
+ /// All endpoints for interacting with the post layer
+ /// </summary>
[ApiController]
[Route("/api/[controller]")]
[Authorize(Roles = "User,Admin")]
@@ -27,6 +30,13 @@ namespace DevHive.Web.Controllers
}
#region Create
+ /// <summary>
+ /// Create a new post
+ /// </summary>
+ /// <param name="userId">The user's Id</param>
+ /// <param name="createPostWebModel">The new post's data</param>
+ /// <param name="authorization">JWT Bearer token</param>
+ /// <returns>New post's Id</returns>
[HttpPost]
public async Task<IActionResult> Create(Guid userId, [FromForm] CreatePostWebModel createPostWebModel, [FromHeader] string authorization)
{
@@ -46,6 +56,11 @@ namespace DevHive.Web.Controllers
#endregion
#region Read
+ /// <summary>
+ /// Query full post's data by it's Id
+ /// </summary>
+ /// <param name="id">The post's Id</param>
+ /// <returns>Full data model of the post</returns>
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> GetById(Guid id)
@@ -58,6 +73,13 @@ namespace DevHive.Web.Controllers
#endregion
#region Update
+ /// <summary>
+ /// Update post's data. Creator only!
+ /// </summary>
+ /// <param name="userId">The post creator's Id</param>
+ /// <param name="updatePostWebModel">The new params of the post</param>
+ /// <param name="authorization">JWT Bearer token</param>
+ /// <returns>The post's Id</returns>
[HttpPut]
public async Task<IActionResult> Update(Guid userId, [FromForm] UpdatePostWebModel updatePostWebModel, [FromHeader] string authorization)
{
@@ -80,13 +102,19 @@ namespace DevHive.Web.Controllers
#endregion
#region Delete
+ /// <summary>
+ /// Delete a post. Creator only!
+ /// </summary>
+ /// <param name="postId">Post's Id</param>
+ /// <param name="authorization">JWT Bearer token</param>
+ /// <returns>Ok result</returns>
[HttpDelete]
- public async Task<IActionResult> Delete(Guid id, [FromHeader] string authorization)
+ public async Task<IActionResult> Delete(Guid postId, [FromHeader] string authorization)
{
- if (!await this._postService.ValidateJwtForPost(id, authorization))
+ if (!await this._postService.ValidateJwtForPost(postId, authorization))
return new UnauthorizedResult();
- return await this._postService.DeletePost(id) ?
+ return await this._postService.DeletePost(postId) ?
new OkResult() :
new BadRequestObjectResult("Could not delete Post");
}