private void FundsDispersedToOrganizationEmail(FundsDispersedToOrganizationEvent evt) { _logger.LogInformation(GetLogMessage("Organization Id: {organization}; InvoiceId: {invoice}; Amount: {amount}"), evt.OrganizationId, evt.InvoiceId, evt.Amount); using (var context = new AppDbContext(DbContextOptions)) { var organization = context.Organizations.Where(a => a.Id == evt.OrganizationId) .Include(a => a.Customer).ThenInclude(a => a.Person).ThenInclude(a => a.ApplicationUser) .First(); var invoice = context.Invoices .Where(a => a.InvoiceId == evt.InvoiceId) .Include(a => a.ProviderOrganization) .Include(a => a.Invoice).Include(a => a.Project) .Include(a => a.OrganizationProjectManager).ThenInclude(a => a.Organization) .First(); var organizationTransferEmail = new OrganizationTransferEmail { RecipientEmail = organization.Customer.Person.ApplicationUser.Email, RecipientName = organization.Customer.Person.FirstName, SendMail = organization.Customer.Person.ApplicationUser.SendMail, Amount = evt.Amount, FlowUrl = Settings.Urls.Flow, Number = invoice.Invoice.Number, ProjectName = invoice.Project.Name, OrganizationName = organization.Name, ProviderOrganizationName = invoice.ProviderOrganization.Name, ProjectManagerOrganizationName = invoice.OrganizationProjectManager.Organization.Name }; Send(TemplateTypes.AgencyOwnerInvoiceDispersedOrganization, organizationTransferEmail, $@"[{organizationTransferEmail.ProviderOrganizationName}] - Payout Notification"); } }
public void Handle(FundsDispersedToOrganizationEvent evt) { Parallel.Invoke(() => { FundsDispersedToOrganizationEmail(evt); }); }