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 bool NewArticle() { using (var service = new MessagedClientService(ConfigurationManager.ConnectionStrings["host"].ConnectionString)) { try { service.NewArticle(new ArticleDto { Id = Guid.Parse(Id), Title = Title, Text = Text }); return true; } catch { return false; } } }
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; } } }