From f986ca67edd425c32eaec5a20fecdc5786f9d8e3 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Wed, 3 Mar 2021 10:27:26 +0200 Subject: Fixing bugs in rating layer --- src/Web/DevHive.Web/Controllers/RatingController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Web/DevHive.Web/Controllers') diff --git a/src/Web/DevHive.Web/Controllers/RatingController.cs b/src/Web/DevHive.Web/Controllers/RatingController.cs index 5716b85..8d3ac92 100644 --- a/src/Web/DevHive.Web/Controllers/RatingController.cs +++ b/src/Web/DevHive.Web/Controllers/RatingController.cs @@ -65,7 +65,7 @@ namespace DevHive.Web.Controllers } [HttpPut] - public async Task UpdateRating(Guid userId, [FromBody] UpdateRatingWebModel updateRatingWebModel, [FromHeader] string authorization) + public async Task UpdateRating(Guid userId, Guid postId, [FromBody] UpdateRatingWebModel updateRatingWebModel, [FromHeader] string authorization) { if (!this._jwtService.ValidateToken(userId, authorization)) return new UnauthorizedResult(); @@ -73,6 +73,7 @@ namespace DevHive.Web.Controllers UpdateRatingServiceModel updateRatingServiceModel = this._mapper.Map(updateRatingWebModel); updateRatingServiceModel.UserId = userId; + updateRatingServiceModel.PostId = postId; ReadRatingServiceModel readRatingServiceModel = await this._rateService.UpdateRating(updateRatingServiceModel); -- cgit v1.2.3 From 4612913c72c3d2b4d3e28629df9f2ed97f0c29a9 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Wed, 3 Mar 2021 10:55:28 +0200 Subject: Moved Rating service models outside of Post folder --- .../Post/Rating/CreateRatingServiceModel.cs | 13 ------------- .../Post/Rating/ReadRatingServiceModel.cs | 15 --------------- .../Post/Rating/UpdateRatingServiceModel.cs | 15 --------------- .../Rating/CreateRatingServiceModel.cs | 13 +++++++++++++ .../Rating/ReadRatingServiceModel.cs | 15 +++++++++++++++ .../Rating/UpdateRatingServiceModel.cs | 15 +++++++++++++++ .../Configurations/Mapping/RatingMappings.cs | 2 +- .../DevHive.Services/Interfaces/IRatingService.cs | 2 +- src/Services/DevHive.Services/Services/RatingService.cs | 2 +- .../DevHive.Web/Configurations/Mapping/RatingMappings.cs | 2 +- src/Web/DevHive.Web/Controllers/RatingController.cs | 2 +- 11 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 src/Services/DevHive.Services.Models/Post/Rating/CreateRatingServiceModel.cs delete mode 100644 src/Services/DevHive.Services.Models/Post/Rating/ReadRatingServiceModel.cs delete mode 100644 src/Services/DevHive.Services.Models/Post/Rating/UpdateRatingServiceModel.cs create mode 100644 src/Services/DevHive.Services.Models/Rating/CreateRatingServiceModel.cs create mode 100644 src/Services/DevHive.Services.Models/Rating/ReadRatingServiceModel.cs create mode 100644 src/Services/DevHive.Services.Models/Rating/UpdateRatingServiceModel.cs (limited to 'src/Web/DevHive.Web/Controllers') diff --git a/src/Services/DevHive.Services.Models/Post/Rating/CreateRatingServiceModel.cs b/src/Services/DevHive.Services.Models/Post/Rating/CreateRatingServiceModel.cs deleted file mode 100644 index aaeab73..0000000 --- a/src/Services/DevHive.Services.Models/Post/Rating/CreateRatingServiceModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace DevHive.Services.Models.Post.Rating -{ - public class CreateRatingServiceModel - { - public Guid UserId { get; set; } - - public Guid PostId { get; set; } - - public bool IsLike { get; set; } - } -} diff --git a/src/Services/DevHive.Services.Models/Post/Rating/ReadRatingServiceModel.cs b/src/Services/DevHive.Services.Models/Post/Rating/ReadRatingServiceModel.cs deleted file mode 100644 index 86b4957..0000000 --- a/src/Services/DevHive.Services.Models/Post/Rating/ReadRatingServiceModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace DevHive.Services.Models.Post.Rating -{ - public class ReadRatingServiceModel - { - public Guid Id { get; set; } - - public Guid PostId { get; set; } - - public Guid UserId { get; set; } - - public bool IsLike { get; set; } - } -} diff --git a/src/Services/DevHive.Services.Models/Post/Rating/UpdateRatingServiceModel.cs b/src/Services/DevHive.Services.Models/Post/Rating/UpdateRatingServiceModel.cs deleted file mode 100644 index 1ea8d8f..0000000 --- a/src/Services/DevHive.Services.Models/Post/Rating/UpdateRatingServiceModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace DevHive.Services.Models.Post.Rating -{ - public class UpdateRatingServiceModel - { - public Guid Id { get; set; } - - public Guid UserId { get; set; } - - public Guid PostId { get; set; } - - public bool IsLike { get; set; } - } -} diff --git a/src/Services/DevHive.Services.Models/Rating/CreateRatingServiceModel.cs b/src/Services/DevHive.Services.Models/Rating/CreateRatingServiceModel.cs new file mode 100644 index 0000000..486e3d2 --- /dev/null +++ b/src/Services/DevHive.Services.Models/Rating/CreateRatingServiceModel.cs @@ -0,0 +1,13 @@ +using System; + +namespace DevHive.Services.Models.Rating +{ + public class CreateRatingServiceModel + { + public Guid UserId { get; set; } + + public Guid PostId { get; set; } + + public bool IsLike { get; set; } + } +} diff --git a/src/Services/DevHive.Services.Models/Rating/ReadRatingServiceModel.cs b/src/Services/DevHive.Services.Models/Rating/ReadRatingServiceModel.cs new file mode 100644 index 0000000..56a5ab0 --- /dev/null +++ b/src/Services/DevHive.Services.Models/Rating/ReadRatingServiceModel.cs @@ -0,0 +1,15 @@ +using System; + +namespace DevHive.Services.Models.Rating +{ + public class ReadRatingServiceModel + { + public Guid Id { get; set; } + + public Guid PostId { get; set; } + + public Guid UserId { get; set; } + + public bool IsLike { get; set; } + } +} diff --git a/src/Services/DevHive.Services.Models/Rating/UpdateRatingServiceModel.cs b/src/Services/DevHive.Services.Models/Rating/UpdateRatingServiceModel.cs new file mode 100644 index 0000000..923e789 --- /dev/null +++ b/src/Services/DevHive.Services.Models/Rating/UpdateRatingServiceModel.cs @@ -0,0 +1,15 @@ +using System; + +namespace DevHive.Services.Models.Rating +{ + public class UpdateRatingServiceModel + { + public Guid Id { get; set; } + + public Guid UserId { get; set; } + + public Guid PostId { get; set; } + + public bool IsLike { get; set; } + } +} diff --git a/src/Services/DevHive.Services/Configurations/Mapping/RatingMappings.cs b/src/Services/DevHive.Services/Configurations/Mapping/RatingMappings.cs index 4534511..9ad5f25 100644 --- a/src/Services/DevHive.Services/Configurations/Mapping/RatingMappings.cs +++ b/src/Services/DevHive.Services/Configurations/Mapping/RatingMappings.cs @@ -1,6 +1,6 @@ using AutoMapper; using DevHive.Data.Models; -using DevHive.Services.Models.Post.Rating; +using DevHive.Services.Models.Rating; namespace DevHive.Services.Configurations.Mapping { diff --git a/src/Services/DevHive.Services/Interfaces/IRatingService.cs b/src/Services/DevHive.Services/Interfaces/IRatingService.cs index b262f45..be33300 100644 --- a/src/Services/DevHive.Services/Interfaces/IRatingService.cs +++ b/src/Services/DevHive.Services/Interfaces/IRatingService.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; using DevHive.Data.Models; -using DevHive.Services.Models.Post.Rating; +using DevHive.Services.Models.Rating; namespace DevHive.Services.Interfaces { diff --git a/src/Services/DevHive.Services/Services/RatingService.cs b/src/Services/DevHive.Services/Services/RatingService.cs index 6d0d0b9..1f77a6e 100644 --- a/src/Services/DevHive.Services/Services/RatingService.cs +++ b/src/Services/DevHive.Services/Services/RatingService.cs @@ -8,7 +8,7 @@ using AutoMapper; using DevHive.Data.Interfaces; using DevHive.Data.Models; using DevHive.Services.Interfaces; -using DevHive.Services.Models.Post.Rating; +using DevHive.Services.Models.Rating; namespace DevHive.Services.Services { diff --git a/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs b/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs index 23c3eeb..1d731d8 100644 --- a/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs +++ b/src/Web/DevHive.Web/Configurations/Mapping/RatingMappings.cs @@ -1,5 +1,5 @@ using AutoMapper; -using DevHive.Services.Models.Post.Rating; +using DevHive.Services.Models.Rating; using DevHive.Web.Models.Rating; namespace DevHive.Web.Configurations.Mapping diff --git a/src/Web/DevHive.Web/Controllers/RatingController.cs b/src/Web/DevHive.Web/Controllers/RatingController.cs index 8d3ac92..c93a56d 100644 --- a/src/Web/DevHive.Web/Controllers/RatingController.cs +++ b/src/Web/DevHive.Web/Controllers/RatingController.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using AutoMapper; using DevHive.Common.Jwt.Interfaces; using DevHive.Services.Interfaces; -using DevHive.Services.Models.Post.Rating; +using DevHive.Services.Models.Rating; using DevHive.Web.Models.Rating; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -- cgit v1.2.3 From 95693f70a2314eab65ac289580d264fe12c42a06 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Wed, 3 Mar 2021 10:56:48 +0200 Subject: Adding authorization to Rating Controller --- src/Web/DevHive.Web/Controllers/RatingController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Web/DevHive.Web/Controllers') diff --git a/src/Web/DevHive.Web/Controllers/RatingController.cs b/src/Web/DevHive.Web/Controllers/RatingController.cs index c93a56d..8c44243 100644 --- a/src/Web/DevHive.Web/Controllers/RatingController.cs +++ b/src/Web/DevHive.Web/Controllers/RatingController.cs @@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Mvc; namespace DevHive.Web.Controllers { [ApiController] - //[Authorize(Roles = "Admin,User")] + [Authorize(Roles = "Admin,User")] [Route("api/[controller]")] public class RatingController { -- cgit v1.2.3 From 6cc1bceebfa1ed01472303db226c000c2345b016 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Wed, 3 Mar 2021 10:57:49 +0200 Subject: Removed _userService from RatingController --- src/Web/DevHive.Web/Controllers/RatingController.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/Web/DevHive.Web/Controllers') diff --git a/src/Web/DevHive.Web/Controllers/RatingController.cs b/src/Web/DevHive.Web/Controllers/RatingController.cs index 8c44243..f6ab0c5 100644 --- a/src/Web/DevHive.Web/Controllers/RatingController.cs +++ b/src/Web/DevHive.Web/Controllers/RatingController.cs @@ -16,14 +16,12 @@ namespace DevHive.Web.Controllers public class RatingController { private readonly IRatingService _rateService; - private readonly IUserService _userService; private readonly IMapper _mapper; private readonly IJwtService _jwtService; - public RatingController(IRatingService rateService, IUserService userService, IMapper mapper, IJwtService jwtService) + public RatingController(IRatingService rateService, IMapper mapper, IJwtService jwtService) { this._rateService = rateService; - this._userService = userService; this._mapper = mapper; this._jwtService = jwtService; } -- cgit v1.2.3 From b3fd74a4207334b7b31e9450a078bd10437648c3 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 13 Mar 2021 08:46:31 +0200 Subject: Fixed type in delete rating method name in rating controller --- src/Web/DevHive.Web/Controllers/RatingController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Web/DevHive.Web/Controllers') diff --git a/src/Web/DevHive.Web/Controllers/RatingController.cs b/src/Web/DevHive.Web/Controllers/RatingController.cs index f6ab0c5..7d21795 100644 --- a/src/Web/DevHive.Web/Controllers/RatingController.cs +++ b/src/Web/DevHive.Web/Controllers/RatingController.cs @@ -85,7 +85,7 @@ namespace DevHive.Web.Controllers } [HttpDelete] - public async Task DeleteTating(Guid userId, Guid ratingId, [FromHeader] string authorization) + public async Task DeleteRating(Guid userId, Guid ratingId, [FromHeader] string authorization) { if (!this._jwtService.ValidateToken(userId, authorization)) return new UnauthorizedResult(); -- cgit v1.2.3 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 --- .../Controllers/TechnologyController.cs | 5 +++ src/Web/DevHive.Web/Controllers/UserController.cs | 52 ++++++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) (limited to 'src/Web/DevHive.Web/Controllers') 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) diff --git a/src/Web/DevHive.Web/Controllers/UserController.cs b/src/Web/DevHive.Web/Controllers/UserController.cs index b01ecc1..86076e5 100644 --- a/src/Web/DevHive.Web/Controllers/UserController.cs +++ b/src/Web/DevHive.Web/Controllers/UserController.cs @@ -8,12 +8,16 @@ using Microsoft.AspNetCore.Mvc; using DevHive.Common.Models.Identity; using DevHive.Services.Interfaces; using DevHive.Common.Jwt.Interfaces; -using DevHive.Web.Models.Attributes; +using NSwag.Annotations; namespace DevHive.Web.Controllers { + /// + /// All endpoints for integration with the User + /// [ApiController] [Route("/api/[controller]")] + [OpenApiController("User Controller")] public class UserController : ControllerBase { private readonly IUserService _userService; @@ -28,9 +32,15 @@ namespace DevHive.Web.Controllers } #region Authentication + /// + /// Login endpoint for the DevHive Social Platform + /// + /// Login model with username and password + /// A JWT Token for further validation [HttpPost] - [Route("Login")] [AllowAnonymous] + [Route("Login")] + [OpenApiTags("Authorization")] public async Task Login([FromBody] LoginWebModel loginModel) { LoginServiceModel loginServiceModel = this._userMapper.Map(loginModel); @@ -41,9 +51,15 @@ namespace DevHive.Web.Controllers return new OkObjectResult(tokenWebModel); } + /// + /// Register a new User in the DevHive Social Platform + /// + /// Register model with the new data to provide + /// A JWT Token for further validation [HttpPost] - [Route("Register")] [AllowAnonymous] + [Route("Register")] + [OpenApiTag("Authorization")] public async Task Register([FromBody] RegisterWebModel registerModel) { RegisterServiceModel registerServiceModel = this._userMapper.Map(registerModel); @@ -56,6 +72,12 @@ namespace DevHive.Web.Controllers #endregion #region Read + /// + /// Get a User's information using the Guid + /// + /// User's Guid + /// The JWT Token, contained in the header and used for validation + /// A full User's read model [HttpGet] [Authorize(Roles = "User,Admin")] public async Task GetById(Guid id, [FromHeader] string authorization) @@ -69,6 +91,11 @@ namespace DevHive.Web.Controllers return new OkObjectResult(userWebModel); } + /// + /// Get a User's profile using his username. Does NOT require authorization + /// + /// User's username + /// A trimmed version of the full User's read model [HttpGet] [Route("GetUser")] [AllowAnonymous] @@ -82,6 +109,13 @@ namespace DevHive.Web.Controllers #endregion #region Update + /// + /// Full update on User's data. A PUSTINQK can only edit his account + /// + /// The User's Guid + /// A full User update model + /// The JWT Token, contained in the header and used for validation + /// A full User's read model [HttpPut] [Authorize(Roles = "User,Admin")] public async Task Update(Guid id, [FromBody] UpdateUserWebModel updateUserWebModel, [FromHeader] string authorization) @@ -100,6 +134,12 @@ namespace DevHive.Web.Controllers #endregion #region Delete + /// + /// Delete a User with his Id. A PUSTINQK can only delete his account. An Admin can delete all accounts + /// + /// The User's Guid + /// The JWT Token, contained in the header and used for validation + /// Ok, BadRequest or Unauthorized [HttpDelete] [Authorize(Roles = "User,Admin")] public async Task Delete(Guid id, [FromHeader] string authorization) @@ -115,7 +155,13 @@ namespace DevHive.Web.Controllers } #endregion + /// + /// We don't talk about that, NIGGA! + /// + /// + /// [HttpPost] + [OpenApiIgnore] [Authorize(Roles = "User,Admin")] [Route("SuperSecretPromotionToAdmin")] public async Task SuperSecretPromotionToAdmin(Guid userId) -- 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') 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