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 Handle(SaveArticleEvent @event) { SectionRecord section = null; List <ArticleRecord> articles; using (var context = new MySqlDbContext()) { section = await context.Sections .FirstOrDefaultAsync(x => x.Id == @event.SectionId); articles = context.Articles .Where(x => x.SectionId == @event.SectionId).ToList(); } if (section != null) { var record = GetRecord(section, articles); await UpdateSection(record); } Sender.Tell(new CommandResult(), Self); }