From f910a2a63cb83b35c6589591400a69c8f7f7917c Mon Sep 17 00:00:00 2001 From: transtrike Date: Sun, 24 Jan 2021 00:07:44 +0200 Subject: Migrations added; CRUD over Posts&Comments successfully completed --- src/DevHive.Web/Controllers/PostController.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/DevHive.Web/Controllers/PostController.cs') diff --git a/src/DevHive.Web/Controllers/PostController.cs b/src/DevHive.Web/Controllers/PostController.cs index 8b8b525..b5e1c98 100644 --- a/src/DevHive.Web/Controllers/PostController.cs +++ b/src/DevHive.Web/Controllers/PostController.cs @@ -31,7 +31,7 @@ namespace DevHive.Web.Controllers { CreatePostServiceModel createPostServiceModel = this._postMapper.Map(createPostWebModel); - createPostServiceModel.IssuerId = userId; + createPostServiceModel.CreatorId = userId; Guid id = await this._postService.CreatePost(createPostServiceModel); @@ -46,7 +46,7 @@ namespace DevHive.Web.Controllers { CreateCommentServiceModel createCommentServiceModel = this._postMapper.Map(createCommentWebModel); - createCommentServiceModel.IssuerId = userId; + createCommentServiceModel.CreatorId = userId; Guid id = await this._postService.AddComment(createCommentServiceModel); @@ -83,11 +83,12 @@ namespace DevHive.Web.Controllers [HttpPut] public async Task Update(Guid userId, [FromBody] UpdatePostWebModel updatePostWebModel, [FromHeader] string authorization) { - if (!await this._postService.ValidateJwtForPost(userId, authorization)) + if (!await this._postService.ValidateJwtForPost(updatePostWebModel.PostId, authorization)) return new UnauthorizedResult(); UpdatePostServiceModel updatePostServiceModel = this._postMapper.Map(updatePostWebModel); + updatePostServiceModel.CreatorId = userId; Guid id = await this._postService.UpdatePost(updatePostServiceModel); @@ -100,11 +101,12 @@ namespace DevHive.Web.Controllers [Route("Comment")] public async Task UpdateComment(Guid userId, [FromBody] UpdateCommentWebModel updateCommentWebModel, [FromHeader] string authorization) { - if (!await this._postService.ValidateJwtForComment(userId, authorization)) + if (!await this._postService.ValidateJwtForComment(updateCommentWebModel.CommentId, authorization)) return new UnauthorizedResult(); UpdateCommentServiceModel updateCommentServiceModel = this._postMapper.Map(updateCommentWebModel); + updateCommentServiceModel.CreatorId = userId; Guid id = await this._postService.UpdateComment(updateCommentServiceModel); -- cgit v1.2.3