示例#1
0
        public Response WriteComment(WriteCommentM comment)
        {
            int      result   = 0;
            Response response = new Response();

            WriteCommentMValidator validator = new WriteCommentMValidator();
            ValidationResult       results   = validator.Validate(comment);

            if (results.Errors.Count > 0)
            {
                throw new ValidationException("입력값을 확인해주세요.", results.Errors.Join("\r\n"), LayerID.BoardController);
            }

            CommentT entity = mapper.Map <WriteCommentM, CommentT>(comment);

            result = boardService.CreateComment(entity);

            if (result > 0)
            {
                response.Status  = ((int)HttpStatusCode.OK).ToString();
                response.Message = "댓글 작성이 완료되었습니다.";
                logger.Log(LogLevel.Info, response.Message);
            }
            else
            {
                throw new BadRequestException("댓글 작성이 실패하였습니다.", "댓글 작성 오류", LayerID.BoardController);
            }

            logger.Log(LogLevel.Info, string.Format("호출 성공 : {0}", MethodBase.GetCurrentMethod().Name));
            return(response);
        }