public async Task <ActionResult> ApproveComment(int commentId, bool isApproved = true) { var comment = commentsRepo.GetCommentById(commentId); if (!User.HasAccessFor(comment.CourseId, CourseRole.Instructor)) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } await commentsRepo.ApproveComment(commentId, isApproved); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public async Task <ActionResult> ApproveComment(int commentId, bool isApproved = true) { var comment = commentsRepo.FindCommentById(commentId); if (comment == null) { return(HttpNotFound()); } if (!CanModerateComments(User, comment.CourseId)) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } await commentsRepo.ApproveComment(commentId, isApproved); if (isApproved) { await NotifyAboutNewComment(comment); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }