aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Web/Controllers/PostController.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-01-24 00:07:44 +0200
committertranstrike <transtrike@gmail.com>2021-01-24 00:07:44 +0200
commitf910a2a63cb83b35c6589591400a69c8f7f7917c (patch)
tree2e601172f734d53ab7a903426ea2d674b5048a76 /src/DevHive.Web/Controllers/PostController.cs
parente01a81954e0fba2c4521e03a76f48a970a87994f (diff)
downloadDevHive-f910a2a63cb83b35c6589591400a69c8f7f7917c.tar
DevHive-f910a2a63cb83b35c6589591400a69c8f7f7917c.tar.gz
DevHive-f910a2a63cb83b35c6589591400a69c8f7f7917c.zip
Migrations added; CRUD over Posts&Comments successfully completed
Diffstat (limited to 'src/DevHive.Web/Controllers/PostController.cs')
-rw-r--r--src/DevHive.Web/Controllers/PostController.cs10
1 files changed, 6 insertions, 4 deletions
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<CreatePostServiceModel>(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<CreateCommentServiceModel>(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<IActionResult> 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<UpdatePostServiceModel>(updatePostWebModel);
+ updatePostServiceModel.CreatorId = userId;
Guid id = await this._postService.UpdatePost(updatePostServiceModel);
@@ -100,11 +101,12 @@ namespace DevHive.Web.Controllers
[Route("Comment")]
public async Task<IActionResult> 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<UpdateCommentServiceModel>(updateCommentWebModel);
+ updateCommentServiceModel.CreatorId = userId;
Guid id = await this._postService.UpdateComment(updateCommentServiceModel);