From 441f04790659a439c0054b7b06130d14cc2eb90b Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 13 Mar 2021 10:01:23 +0200 Subject: Technology xml comments added; Needs finish --- src/Web/DevHive.Web/Controllers/TechnologyController.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Web/DevHive.Web/Controllers/TechnologyController.cs') diff --git a/src/Web/DevHive.Web/Controllers/TechnologyController.cs b/src/Web/DevHive.Web/Controllers/TechnologyController.cs index e507899..ba3f04a 100644 --- a/src/Web/DevHive.Web/Controllers/TechnologyController.cs +++ b/src/Web/DevHive.Web/Controllers/TechnologyController.cs @@ -23,6 +23,11 @@ namespace DevHive.Web.Controllers this._technologyMapper = technologyMapper; } + /// + /// Create a new technology, so users can have a choice. Admin only! + /// + /// Data for the new technology + /// [HttpPost] [Authorize(Roles = "Admin")] public async Task Create([FromBody] CreateTechnologyWebModel createTechnologyWebModel) -- cgit v1.2.3 From 93ded2b68a31fc9da643ac65955219e4f306ab82 Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 13 Mar 2021 11:44:01 +0200 Subject: XML Docs on all controllers --- .../DevHive.Web/Controllers/CommentController.cs | 38 +++++++++++++++++++--- src/Web/DevHive.Web/Controllers/FeedController.cs | 15 +++++++++ .../DevHive.Web/Controllers/LanguageController.cs | 32 ++++++++++++++++-- src/Web/DevHive.Web/Controllers/PostController.cs | 34 +++++++++++++++++-- .../Controllers/ProfilePictureController.cs | 18 +++++++++- src/Web/DevHive.Web/Controllers/RoleController.cs | 24 ++++++++++++++ .../Controllers/TechnologyController.cs | 25 +++++++++++++- src/Web/DevHive.Web/Controllers/UserController.cs | 6 ++-- src/Web/DevHive.Web/DevHive.Web.csproj | 5 ++- 9 files changed, 181 insertions(+), 16 deletions(-) (limited to 'src/Web/DevHive.Web/Controllers/TechnologyController.cs') 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 { + /// + /// All endpoints for interacting with the comments layer + /// [ApiController] [Route("/api/[controller]")] [Authorize(Roles = "User,Admin")] @@ -26,6 +29,13 @@ namespace DevHive.Web.Controllers this._jwtService = jwtService; } + /// + /// Create a comment and attach it to a post + /// + /// The useer's Id + /// The new comment's parametars + /// JWT Bearer token + /// The comment's Id [HttpPost] public async Task AddComment(Guid userId, [FromBody] CreateCommentWebModel createCommentWebModel, [FromHeader] string authorization) { @@ -46,16 +56,28 @@ namespace DevHive.Web.Controllers new OkObjectResult(new { Id = id }); } + /// + /// Query comment's data by it's Id + /// + /// The comment's Id + /// Full data model of the comment [HttpGet] [AllowAnonymous] - public async Task GetCommentById(Guid id) + public async Task GetCommentById(Guid commentId) { - ReadCommentServiceModel readCommentServiceModel = await this._commentService.GetCommentById(id); + ReadCommentServiceModel readCommentServiceModel = await this._commentService.GetCommentById(commentId); ReadCommentWebModel readCommentWebModel = this._commentMapper.Map(readCommentServiceModel); return new OkObjectResult(readCommentWebModel); } + /// + /// Update comment's parametars. Comment creator only! + /// + /// The comment creator's Id + /// New comment's parametars + /// JWT Bearer token + /// Ok result [HttpPut] public async Task UpdateComment(Guid userId, [FromBody] UpdateCommentWebModel updateCommentWebModel, [FromHeader] string authorization) { @@ -73,13 +95,19 @@ namespace DevHive.Web.Controllers new OkObjectResult(new { Id = id }); } + /// + /// Delete a comment. Comment creator only! + /// + /// Comment's Id + /// JWT Bearer token + /// Ok result [HttpDelete] - public async Task DeleteComment(Guid id, [FromHeader] string authorization) + public async Task 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"); } diff --git a/src/Web/DevHive.Web/Controllers/FeedController.cs b/src/Web/DevHive.Web/Controllers/FeedController.cs index abca3e4..37532a9 100644 --- a/src/Web/DevHive.Web/Controllers/FeedController.cs +++ b/src/Web/DevHive.Web/Controllers/FeedController.cs @@ -10,6 +10,9 @@ using Microsoft.AspNetCore.Mvc; namespace DevHive.Web.Controllers { + /// + /// All endpoints for interacting with the feed layer + /// [ApiController] [Route("/api/[controller]")] [Authorize(Roles = "User,Admin")] @@ -24,6 +27,12 @@ namespace DevHive.Web.Controllers this._mapper = mapper; } + /// + /// Query posts for user's feed + /// + /// The user's Id, whose feed is begin queried + /// Page parametars + /// A page of the feed [HttpPost] [Route("GetPosts")] public async Task GetPosts(Guid userId, [FromBody] GetPageWebModel getPageWebModel) @@ -37,6 +46,12 @@ namespace DevHive.Web.Controllers return new OkObjectResult(readPageWebModel); } + /// + /// Query a user profile's posts + /// + /// The user's username, whose posts are being queried + /// Page parametars + /// A page of the user's posts [HttpPost] [Route("GetUserPosts")] [AllowAnonymous] diff --git a/src/Web/DevHive.Web/Controllers/LanguageController.cs b/src/Web/DevHive.Web/Controllers/LanguageController.cs index 5b0d5de..665fb66 100644 --- a/src/Web/DevHive.Web/Controllers/LanguageController.cs +++ b/src/Web/DevHive.Web/Controllers/LanguageController.cs @@ -10,6 +10,9 @@ using Microsoft.AspNetCore.Mvc; namespace DevHive.Web.Controllers { + /// + /// All endpoints for interacting with the language layer + /// [ApiController] [Route("/api/[controller]")] public class LanguageController @@ -23,6 +26,11 @@ namespace DevHive.Web.Controllers this._languageMapper = mapper; } + /// + /// Create a new language, so users can have a choice. Admin only! + /// + /// The new language's parametars + /// The new language's Id [HttpPost] [Authorize(Roles = "Admin")] public async Task Create([FromBody] CreateLanguageWebModel createLanguageWebModel) @@ -36,6 +44,11 @@ namespace DevHive.Web.Controllers new OkObjectResult(new { Id = id }); } + /// + /// Query full language data by Id + /// + /// The language's Id + /// Full language data [HttpGet] [AllowAnonymous] public async Task GetById(Guid id) @@ -46,6 +59,10 @@ namespace DevHive.Web.Controllers return new OkObjectResult(languageWebModel); } + /// + /// Query all languages in the database + /// + /// All languages in the database [HttpGet] [Route("GetLanguages")] [Authorize(Roles = "User,Admin")] @@ -57,6 +74,12 @@ namespace DevHive.Web.Controllers return new OkObjectResult(languageWebModels); } + /// + /// Alter language's properties. Admin only! + /// + /// The language's Id + /// The langauge's new parametars + /// Ok result [HttpPut] [Authorize(Roles = "Admin")] public async Task Update(Guid id, [FromBody] UpdateLanguageWebModel updateModel) @@ -72,11 +95,16 @@ namespace DevHive.Web.Controllers return new OkResult(); } + /// + /// Delete a language. Admin only! + /// + /// The language's Id + /// Ok result [HttpDelete] [Authorize(Roles = "Admin")] - public async Task Delete(Guid id) + public async Task Delete(Guid langaugeId) { - bool result = await this._languageService.DeleteLanguage(id); + bool result = await this._languageService.DeleteLanguage(langaugeId); if (!result) return new BadRequestObjectResult("Could not delete Language"); 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 { + /// + /// All endpoints for interacting with the post layer + /// [ApiController] [Route("/api/[controller]")] [Authorize(Roles = "User,Admin")] @@ -27,6 +30,13 @@ namespace DevHive.Web.Controllers } #region Create + /// + /// Create a new post + /// + /// The user's Id + /// The new post's data + /// JWT Bearer token + /// New post's Id [HttpPost] public async Task Create(Guid userId, [FromForm] CreatePostWebModel createPostWebModel, [FromHeader] string authorization) { @@ -46,6 +56,11 @@ namespace DevHive.Web.Controllers #endregion #region Read + /// + /// Query full post's data by it's Id + /// + /// The post's Id + /// Full data model of the post [HttpGet] [AllowAnonymous] public async Task GetById(Guid id) @@ -58,6 +73,13 @@ namespace DevHive.Web.Controllers #endregion #region Update + /// + /// Update post's data. Creator only! + /// + /// The post creator's Id + /// The new params of the post + /// JWT Bearer token + /// The post's Id [HttpPut] public async Task Update(Guid userId, [FromForm] UpdatePostWebModel updatePostWebModel, [FromHeader] string authorization) { @@ -80,13 +102,19 @@ namespace DevHive.Web.Controllers #endregion #region Delete + /// + /// Delete a post. Creator only! + /// + /// Post's Id + /// JWT Bearer token + /// Ok result [HttpDelete] - public async Task Delete(Guid id, [FromHeader] string authorization) + public async Task 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"); } diff --git a/src/Web/DevHive.Web/Controllers/ProfilePictureController.cs b/src/Web/DevHive.Web/Controllers/ProfilePictureController.cs index d3971ff..2eec99e 100644 --- a/src/Web/DevHive.Web/Controllers/ProfilePictureController.cs +++ b/src/Web/DevHive.Web/Controllers/ProfilePictureController.cs @@ -1,16 +1,32 @@ using System; using System.Threading.Tasks; -using DevHive.Services.Models.User; using DevHive.Web.Models.User; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace DevHive.Web.Controllers { + /// + /// All endpoints for interacting with the profile picture layer + /// [ApiController] [Route("api/[controller]")] public class ProfilePictureController { + // private readonly ProfilePictureService _profilePictureService; + + // public ProfilePictureController(ProfilePictureService profilePictureService) + // { + // this._profilePictureService = profilePictureService; + // } + + /// + /// Alter the profile picture of a user + /// + /// The user's Id + /// The new profile picture + /// JWT Bearer Token + /// ??? [HttpPut] [Route("ProfilePicture")] [Authorize(Roles = "User,Admin")] diff --git a/src/Web/DevHive.Web/Controllers/RoleController.cs b/src/Web/DevHive.Web/Controllers/RoleController.cs index 1465795..ebb305e 100644 --- a/src/Web/DevHive.Web/Controllers/RoleController.cs +++ b/src/Web/DevHive.Web/Controllers/RoleController.cs @@ -9,6 +9,9 @@ using Microsoft.AspNetCore.Authorization; namespace DevHive.Web.Controllers { + /// + /// All endpoints for interacting with the roles layer + /// [ApiController] [Route("/api/[controller]")] public class RoleController @@ -22,6 +25,11 @@ namespace DevHive.Web.Controllers this._roleMapper = mapper; } + /// + /// Create a new role for the roles hierarchy. Admin only! + /// + /// The new role's parametars + /// The new role's Id [HttpPost] [Authorize(Roles = "Admin")] public async Task Create([FromBody] CreateRoleWebModel createRoleWebModel) @@ -36,6 +44,11 @@ namespace DevHive.Web.Controllers new OkObjectResult(new { Id = id }); } + /// + /// Get a role's full data, querying it by it's Id + /// + /// The role's Id + /// Full info of the role [HttpGet] [Authorize(Roles = "User,Admin")] public async Task GetById(Guid id) @@ -46,6 +59,12 @@ namespace DevHive.Web.Controllers return new OkObjectResult(roleWebModel); } + /// + /// Update a role's parametars. Admin only! + /// + /// The role's Id + /// The new parametrats for that role + /// Ok result [HttpPut] [Authorize(Roles = "Admin")] public async Task Update(Guid id, [FromBody] UpdateRoleWebModel updateRoleWebModel) @@ -62,6 +81,11 @@ namespace DevHive.Web.Controllers return new OkResult(); } + /// + /// Delete a role. Admin only! + /// + /// The role's Id + /// Ok result [HttpDelete] [Authorize(Roles = "Admin")] public async Task Delete(Guid id) diff --git a/src/Web/DevHive.Web/Controllers/TechnologyController.cs b/src/Web/DevHive.Web/Controllers/TechnologyController.cs index ba3f04a..ecf2bd7 100644 --- a/src/Web/DevHive.Web/Controllers/TechnologyController.cs +++ b/src/Web/DevHive.Web/Controllers/TechnologyController.cs @@ -10,6 +10,9 @@ using Microsoft.AspNetCore.Mvc; namespace DevHive.Web.Controllers { + /// + /// All endpoints for interacting with the technology layer + /// [ApiController] [Route("/api/[controller]")] public class TechnologyController @@ -27,7 +30,7 @@ namespace DevHive.Web.Controllers /// Create a new technology, so users can have a choice. Admin only! /// /// Data for the new technology - /// + /// The new technology's Id [HttpPost] [Authorize(Roles = "Admin")] public async Task Create([FromBody] CreateTechnologyWebModel createTechnologyWebModel) @@ -41,6 +44,11 @@ namespace DevHive.Web.Controllers new OkObjectResult(new { Id = id }); } + /// + /// Get technology's data by it's Id + /// + /// The technology's Id + /// The technology's full data [HttpGet] [AllowAnonymous] public async Task GetById(Guid id) @@ -51,6 +59,10 @@ namespace DevHive.Web.Controllers return new OkObjectResult(readTechnologyWebModel); } + /// + /// Get all technologies from our database + /// + /// All technologies [HttpGet] [Route("GetTechnologies")] [Authorize(Roles = "User,Admin")] @@ -62,6 +74,12 @@ namespace DevHive.Web.Controllers return new OkObjectResult(languageWebModels); } + /// + /// Alter a technology's parameters. Admin only! + /// + /// Technology's Id + /// The new parametars + /// Ok result [HttpPut] [Authorize(Roles = "Admin")] public async Task Update(Guid id, [FromBody] UpdateTechnologyWebModel updateModel) @@ -77,6 +95,11 @@ namespace DevHive.Web.Controllers return new OkResult(); } + /// + /// Delete a etchnology from the database. Admin only! + /// + /// The technology's Id + /// Ok result [HttpDelete] [Authorize(Roles = "Admin")] public async Task Delete(Guid id) diff --git a/src/Web/DevHive.Web/Controllers/UserController.cs b/src/Web/DevHive.Web/Controllers/UserController.cs index 86076e5..4d01447 100644 --- a/src/Web/DevHive.Web/Controllers/UserController.cs +++ b/src/Web/DevHive.Web/Controllers/UserController.cs @@ -75,7 +75,7 @@ namespace DevHive.Web.Controllers /// /// Get a User's information using the Guid /// - /// User's Guid + /// User's Id /// The JWT Token, contained in the header and used for validation /// A full User's read model [HttpGet] @@ -112,7 +112,7 @@ namespace DevHive.Web.Controllers /// /// Full update on User's data. A PUSTINQK can only edit his account /// - /// The User's Guid + /// The User's Id /// A full User update model /// The JWT Token, contained in the header and used for validation /// A full User's read model @@ -137,7 +137,7 @@ namespace DevHive.Web.Controllers /// /// Delete a User with his Id. A PUSTINQK can only delete his account. An Admin can delete all accounts /// - /// The User's Guid + /// The User's Id /// The JWT Token, contained in the header and used for validation /// Ok, BadRequest or Unauthorized [HttpDelete] diff --git a/src/Web/DevHive.Web/DevHive.Web.csproj b/src/Web/DevHive.Web/DevHive.Web.csproj index 38f21e6..39322ae 100644 --- a/src/Web/DevHive.Web/DevHive.Web.csproj +++ b/src/Web/DevHive.Web/DevHive.Web.csproj @@ -25,6 +25,9 @@ + + + @@ -32,4 +35,4 @@ - + \ No newline at end of file -- cgit v1.2.3