private async Task Handle(SaveArticleEvent @event) { ArticleRecord article; using (var context = new MySqlDbContext()) { article = await context.Articles .FirstOrDefaultAsync((x => x.Id == @event.Id)); } if (article != null) { var record = new ArticleDetailsRecord { Id = article.Id, Title = article.Title, Date = article.Date, Text = article.Text, ImageUrl = article.ImageUrl }; await SaveArticle(record); } Sender.Tell(new CommandResult(), Self); }
private async Task SaveArticle(ArticleDetailsRecord article) { var collection = _mongoDb.GetCollection <ArticleDetailsRecord>("articles"); await collection.InsertOneAsync(article); }