Пример #1
0
        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);
            }
        }
Пример #2
0
 private bool AddArticleComment()
 {
     if (string.IsNullOrEmpty(ArticleId))
     {
         ArticleId = Args[0];
     }
     using (var service = new MessagedClientService(ConfigurationManager.ConnectionStrings["host"].ConnectionString))
     {
         try
         {
             service.NewComment(ArticleId, new CommentDto
             {
                 ArticleId = Guid.Parse(ArticleId),
                 Id = Guid.Parse(Id),
                 Text = Text
             });
             return true;
         }
         catch
         {
             return false;
         }
     }
 }