Example #1
0
 public void Check_CommentText_Valid(int commentLength)
 {
     string text = GetStringWithDesiredLength(commentLength);
     var comment = new CommentDto {Text = text};
     string[] errors;
     bool valid = comment.Validate(out errors);
     Assert.True(valid, string.Join(";", errors));
 }
Example #2
0
 public void AddComment(string articleId, CommentDto comment)
 {
     string[] validationErrors;
     if (!comment.Validate(out validationErrors))
     {
         throw new WebFaultException<WebFaultDto>(
             new WebFaultDto("Не удалось добавить комментарий", string.Join("\n", validationErrors)),
             HttpStatusCode.BadRequest);
     }
     try
     {
         _commandRepository.CreateComment(Guid.Parse(articleId), _mapper.Map<Comment>(comment));
     }
     catch (Exception ex)
     {
         throw new WebFaultException<WebFaultDto>(
             new WebFaultDto("Ошибка при добавлении комментария к статье", ex.Message),
             HttpStatusCode.InternalServerError);
     }
 }