public async Task Handle(PolicyCreated notification, CancellationToken cancellationToken) { var policy = new PolicyAccount(notification.PolicyNumber, policyAccountNumberGenerator.Generate()); using (dataStore) { dataStore.PolicyAccounts.Add(policy); await dataStore.CommitChanges(); } }
public async Task Handle(PolicyCreated notification, CancellationToken cancellationToken) { var policy = new PolicyAccount(notification.PolicyNumber, policyAccountNumberGenerator.Generate()); using (unitOfWork) { unitOfWork.PolicyAccounts.Add(policy); unitOfWork.CommitChanges(); } }
public async Task Handle(PolicyCreated notification, CancellationToken cancellationToken) { var policy = new PolicyAccount ( notification.PolicyNumber, policyAccountNumberGenerator.Generate(), notification.PolicyHolder.FirstName, notification.PolicyHolder.LastName ); using (dataStore) { if (await dataStore.PolicyAccounts.ExistsWithPolicyNumber(notification.PolicyNumber)) { return; } dataStore.PolicyAccounts.Add(policy); await dataStore.CommitChanges(); } }