Exemplo n.º 1
0
        public virtual void Delete(int id)
        {
            try
            {
                var comment = new GetDeleteCommentInput {
                    Id = id
                };
                var results = _getDeleteCommentValidator.Validate(comment, "Id");

                if (!results.IsValid)
                {
                    throw new ValidationException(results.Errors);
                }

                _unitOfWork.GetComments().Delete(id);
                _unitOfWork.Save();
            }
            catch (ValidationException exception)
            {
                _logger.Warn(exception.Message);
                throw;
            }
            catch (Exception exception)
            {
                _logger.Trace(exception.StackTrace);
                throw;
            }
        }
Exemplo n.º 2
0
        public CommentOutput Get(int id)
        {
            try
            {
                var comment = new GetDeleteCommentInput {
                    Id = id
                };
                var validationResults = _getDeleteCommentValidator.Validate(comment, "Id");

                if (!validationResults.IsValid)
                {
                    throw new ValidationException(validationResults.Errors);
                }

                var query = _unitOfWork.GetComments().Get(id);
                return(Mapper.Map <CommentOutput>(query));
            }
            catch (ValidationException exception)
            {
                _logger.Warn(exception.Message);
                throw;
            }
            catch (Exception exception)
            {
                _logger.Trace(exception.StackTrace);
                throw;
            }
        }