コード例 #1
0
ファイル: CommentFactory.cs プロジェクト: gobixm/learn
 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;
 }
コード例 #2
0
ファイル: AddArticleComment.cs プロジェクト: gobixm/learn
        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);
            }
        }
コード例 #3
0
ファイル: MessagedClientService.cs プロジェクト: gobixm/learn
 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()));
     }
 }
コード例 #4
0
ファイル: CommentViewModel.cs プロジェクト: gobixm/learn
 public CommentViewModel(CommentDto comment, IClientService clientService)
 {
     Comment = comment;
     _clientService = clientService;
 }