Beispiel #1
0
        public async Task <IActionResult> insertComment([FromBody] CommentModelInsert model)
        {
            var accessToken = Request.Headers[HeaderNames.Authorization];

            var result = await _commentService.insertComment(model, accessToken);

            return(result);
        }
Beispiel #2
0
        public async Task <ResponseEntity> insertComment(CommentModelInsert model, string token)
        {
            try
            {
                var     userJira = _userService.getUserByToken(token).Result;
                Comment cmt      = new Comment();
                cmt.alias          = FuncUtilities.BestLower(model.contentComment);
                cmt.deleted        = false;
                cmt.contentComment = FuncUtilities.Base64Encode(model.contentComment);
                cmt.userId         = userJira.id;
                cmt.taskId         = model.taskId;
                cmt = await _commentRepository.InsertAsync(cmt);

                if (cmt == null)
                {
                    return(new ResponseEntity(StatusCodeConstants.ERROR_SERVER, model, MessageConstants.INSERT_ERROR));
                }
                cmt.contentComment = FuncUtilities.Base64Decode(cmt.contentComment);
                return(new ResponseEntity(StatusCodeConstants.OK, cmt, MessageConstants.INSERT_SUCCESS));
            }catch (Exception ex)
            {
                return(new ResponseEntity(StatusCodeConstants.AUTHORIZATION, "Unauthorize", MessageConstants.MESSAGE_ERROR_401));
            }
        }