Ejemplo n.º 1
0
        public async Task <ActionResult> DeleteExerciseCodeReviewComment([FromRoute] int reviewId, [FromRoute] int commentId)
        {
            var comment = await slideCheckingsRepo.FindExerciseCodeReviewCommentById(commentId);

            if (comment == null)
            {
                return(NotFound(new ErrorResponse($"Comment {commentId} not found")));
            }

            var courseId = comment.Review.ExerciseCheckingId.HasValue ? comment.Review.ExerciseChecking.CourseId : comment.Review.Submission.CourseId;

            if (comment.AuthorId != UserId && !await courseRolesRepo.HasUserAccessToCourse(UserId, courseId, CourseRoleType.CourseAdmin))
            {
                return(StatusCode((int)HttpStatusCode.Forbidden, new ErrorResponse("You can't delete this comment")));
            }

            await slideCheckingsRepo.DeleteExerciseCodeReviewComment(comment).ConfigureAwait(false);

            return(Ok(new SuccessResponseWithMessage($"Review comment {commentId} successfully deleted")));
        }