public ActionResult Update(CommentUpdateInput updateInput) { if (updateInput.ContributionId.Contains("observations/") && !_userContext.HasGroupPermission <Observation>(updateInput.ContributionId, PermissionNames.UpdateComment)) { return(new HttpUnauthorizedResult()); } if (updateInput.ContributionId.Contains("posts/") && !_userContext.HasGroupPermission <Post>(updateInput.ContributionId, PermissionNames.UpdateComment)) { return(new HttpUnauthorizedResult()); } if (!ModelState.IsValid) { return(JsonFailed()); } _messageBus.Send( new CommentUpdateCommand() { UserId = _userContext.GetAuthenticatedUserId(), Id = updateInput.CommentId, Comment = updateInput.Comment, ContributionId = updateInput.ContributionId, UpdatedOn = DateTime.UtcNow }); return(JsonSuccess()); }
public ActionResult Create(CommentUpdateInput createInput) { if (createInput.ContributionId.Contains("observations/") && !_userContext.HasGroupPermission <Observation>(PermissionNames.CreateComment, createInput.ContributionId)) { return(new HttpUnauthorizedResult()); } if (createInput.ContributionId.Contains("posts/") && !_userContext.HasGroupPermission <Post>(PermissionNames.CreateComment, createInput.ContributionId)) { return(new HttpUnauthorizedResult()); } if (!ModelState.IsValid) { return(JsonFailed()); } _messageBus.Send( new CommentCreateCommand() { UserId = _userContext.GetAuthenticatedUserId(), //Comment = createInput.Message, CommentedOn = DateTime.UtcNow, ContributionId = createInput.ContributionId, //InReplyToCommentId = createInput.ParentCommentId }); return(JsonSuccess()); }