public Comment CreateComment(CommentDto commentDto) { var state = _mappingService.Map<CommentState>(commentDto); Comment comment = Comment.Create(state); string[] errors; if (!_validator.Validate(comment, out errors)) { throw new ArgumentException(string.Join("\n", errors)); } return comment; }
protected override void ProcessRecord() { var client = new MessagedClientService(ConnectionString); try { var comment = new CommentDto { Id = Guid.NewGuid(), ArticleId = Article, Text = Text }; client.NewComment(Article.ToString(), comment); WriteVerbose("Комментарий c id " + comment.Id + " добавлен"); } catch (DataServiceException ex) { Console.WriteLine("Не удалось добавить комментарий:" + ex.Message); } }
public void NewComment(string articleId, CommentDto comment) { try { _webClient.Post(new AddArticleCommentRequest { ArticleId = articleId, Comment = comment }); } catch (Exception ex) { throw new DataServiceException(new FaultDto(ex.Message, ex.ToString())); } }
public CommentViewModel(CommentDto comment, IClientService clientService) { Comment = comment; _clientService = clientService; }