public async Task <IActionResult> PatchComment([FromBody] TicketCommentViewModel ticketComment)
        {
            if (!(await _authService.AuthorizeProjectRoleByComment(eProjectRoles.Manager, ticketComment.CommentId)))
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }

            _logger.LogInformation($"PatchComment Comment id: {ticketComment.CommentId}, comment: {ticketComment.Comment}");
            _ticketService.EditComment(ticketComment.CommentId, ticketComment.Comment);
            return(new AcceptedResult());
        }
Beispiel #2
0
        public async Task <IActionResult> CommentDelete([FromRoute] long id)
        {
            var keyAuthResult = await _authService.AuthByApiKey();

            if (keyAuthResult.User == null)
            {
                return(BadRequest(ErrorResponse.GetErrorList(keyAuthResult.ErrorText)));
            }

            if (_ticketService.GetComment(id) == null)
            {
                return(NotFound(ErrorResponse.GetErrorList($"Comment with Id: {id} was not found")));
            }

            if (!await _authService.AuthorizeProjectRoleByComment(eProjectRoles.Manager, id, keyAuthResult.User))
            {
                return(Unauthorized(ErrorResponse.GetUnauthorizedErrorList(keyAuthResult.User.Identity.Name, eProjectRoles.Manager)));
            }

            if (_ticketService.DeleteComment(id))
            {
                return(NoContent());
            }
            return(NotFound(ErrorResponse.GetErrorList($"Comment with Id: {id} was not found")));
        }