diff options
| author | transtrike <transtrike@gmail.com> | 2021-03-13 11:44:01 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-03-13 11:44:25 +0200 |
| commit | 93ded2b68a31fc9da643ac65955219e4f306ab82 (patch) | |
| tree | 9647a722d5974337f999da34b9a023114b0a9324 /src/Web/DevHive.Web/Controllers/CommentController.cs | |
| parent | 441f04790659a439c0054b7b06130d14cc2eb90b (diff) | |
| download | DevHive-93ded2b68a31fc9da643ac65955219e4f306ab82.tar DevHive-93ded2b68a31fc9da643ac65955219e4f306ab82.tar.gz DevHive-93ded2b68a31fc9da643ac65955219e4f306ab82.zip | |
XML Docs on all controllers
Diffstat (limited to 'src/Web/DevHive.Web/Controllers/CommentController.cs')
| -rw-r--r-- | src/Web/DevHive.Web/Controllers/CommentController.cs | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/Web/DevHive.Web/Controllers/CommentController.cs b/src/Web/DevHive.Web/Controllers/CommentController.cs index 1722801..8fa3577 100644 --- a/src/Web/DevHive.Web/Controllers/CommentController.cs +++ b/src/Web/DevHive.Web/Controllers/CommentController.cs @@ -10,6 +10,9 @@ using DevHive.Common.Jwt.Interfaces; namespace DevHive.Web.Controllers { + /// <summary> + /// All endpoints for interacting with the comments layer + /// </summary> [ApiController] [Route("/api/[controller]")] [Authorize(Roles = "User,Admin")] @@ -26,6 +29,13 @@ namespace DevHive.Web.Controllers this._jwtService = jwtService; } + /// <summary> + /// Create a comment and attach it to a post + /// </summary> + /// <param name="userId">The useer's Id</param> + /// <param name="createCommentWebModel">The new comment's parametars</param> + /// <param name="authorization">JWT Bearer token</param> + /// <returns>The comment's Id</returns> [HttpPost] public async Task<IActionResult> AddComment(Guid userId, [FromBody] CreateCommentWebModel createCommentWebModel, [FromHeader] string authorization) { @@ -46,16 +56,28 @@ namespace DevHive.Web.Controllers new OkObjectResult(new { Id = id }); } + /// <summary> + /// Query comment's data by it's Id + /// </summary> + /// <param name="commentId">The comment's Id</param> + /// <returns>Full data model of the comment</returns> [HttpGet] [AllowAnonymous] - public async Task<IActionResult> GetCommentById(Guid id) + public async Task<IActionResult> GetCommentById(Guid commentId) { - ReadCommentServiceModel readCommentServiceModel = await this._commentService.GetCommentById(id); + ReadCommentServiceModel readCommentServiceModel = await this._commentService.GetCommentById(commentId); ReadCommentWebModel readCommentWebModel = this._commentMapper.Map<ReadCommentWebModel>(readCommentServiceModel); return new OkObjectResult(readCommentWebModel); } + /// <summary> + /// Update comment's parametars. Comment creator only! + /// </summary> + /// <param name="userId">The comment creator's Id</param> + /// <param name="updateCommentWebModel">New comment's parametars</param> + /// <param name="authorization">JWT Bearer token</param> + /// <returns>Ok result</returns> [HttpPut] public async Task<IActionResult> UpdateComment(Guid userId, [FromBody] UpdateCommentWebModel updateCommentWebModel, [FromHeader] string authorization) { @@ -73,13 +95,19 @@ namespace DevHive.Web.Controllers new OkObjectResult(new { Id = id }); } + /// <summary> + /// Delete a comment. Comment creator only! + /// </summary> + /// <param name="commentId">Comment's Id</param> + /// <param name="authorization">JWT Bearer token</param> + /// <returns>Ok result</returns> [HttpDelete] - public async Task<IActionResult> DeleteComment(Guid id, [FromHeader] string authorization) + public async Task<IActionResult> DeleteComment(Guid commentId, [FromHeader] string authorization) { - if (!await this._commentService.ValidateJwtForComment(id, authorization)) + if (!await this._commentService.ValidateJwtForComment(commentId, authorization)) return new UnauthorizedResult(); - return await this._commentService.DeleteComment(id) ? + return await this._commentService.DeleteComment(commentId) ? new OkResult() : new BadRequestObjectResult("Could not delete Comment"); } |
