private void AddIfNotExists(PolicyAccount account) { if (uow.PolicyAccounts.FindByNumber(account.PolicyNumber) == null) { uow.PolicyAccounts.Add(account); } }
private async Task AddIfNotExists(PolicyAccount account) { if (await dataStore.PolicyAccounts.FindByNumber(account.PolicyNumber) == null) { dataStore.PolicyAccounts.Add(account); } }
public void CanRegisterExpectdPayment() { var dueDate = new DateTimeOffset(new DateTime(2018, 1, 1)); PolicyAccount account = new PolicyAccount("C", "C"); account.ExpectedPayment(10M, dueDate); Equal(1, account.Entries.Count); Equal(-10M, account.BalanceAt(dueDate)); }
public void CanRegisterOutpayment() { var paymentReleaseDate = new DateTimeOffset(new DateTime(2018, 1, 1)); PolicyAccount account = new PolicyAccount("B", "B"); account.OutPayment(10M, paymentReleaseDate); Equal(1, account.Entries.Count); Equal(-10M, account.BalanceAt(paymentReleaseDate)); }
public void CanRegisterInPayment() { var incomeDate = new DateTimeOffset(new DateTime(2018, 1, 1)); PolicyAccount account = new PolicyAccount("A", "A"); account.InPayment(10M, incomeDate); Equal(1, account.Entries.Count); Equal(10M, account.BalanceAt(incomeDate)); }
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()); using (dataStore) { dataStore.PolicyAccounts.Add(policy); await dataStore.CommitChanges(); } }
public void CanCloseAccountAndReturnMoney() { var dueDate = new DateTimeOffset(new DateTime(2018, 1, 1)); var account = new PolicyAccount("C", "C", "E", "E"); account.ExpectedPayment(10M, dueDate); account.InPayment(10M, dueDate); account.Close(new DateTime(2018, 6, 1), 5M); Equal(PolicyAccountStatus.Terminated, account.Status); }
public void CanProperlyCalculateBalance() { var dueDate1 = new DateTimeOffset(new DateTime(2018, 1, 1)); var dueDate2 = new DateTimeOffset(new DateTime(2018, 10, 1)); var incomeDate = new DateTimeOffset(new DateTime(2018, 5, 1)); PolicyAccount account = new PolicyAccount("D", "D"); account.ExpectedPayment(10M, dueDate1); account.ExpectedPayment(15M, dueDate2); account.InPayment(25M, incomeDate); Equal(-10M, account.BalanceAt(dueDate1)); Equal(15M, account.BalanceAt(incomeDate)); Equal(0M, account.BalanceAt(dueDate2)); }
public Task <CreateAccountForPolicyResponseDto> Handle(CreateAccountForPolicyRequestDto request, CancellationToken cancellationToken) { var isAccountAlreadyExists = dbContext.PolicyAccount.Any(x => x.PolicyNumber == request.PolicyNumber); if (isAccountAlreadyExists) { throw new PolicyAccountAlreadyExists(request.PolicyNumber); } var policyAccount = new PolicyAccount(request); dbContext.PolicyAccount.Add(policyAccount); dbContext.SaveChanges(); //TODO: should be something in response or maybe response is not need at all var response = new CreateAccountForPolicyResponseDto(); return(Task.FromResult(response)); }
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(); } }
public async Task <PolicyAccountResponse> Handle(PolicyAccountCommand request, CancellationToken cancellationToken) { var policyAccountNumber = Guid.NewGuid().ToString(); var policy = new PolicyAccount ( request.PolicyNumber, policyAccountNumber, request.PolicyHolder.FirstName, request.PolicyHolder.LastName ); using (_dataStore) { if (await _dataStore.PolicyAccounts.ExistsWithPolicyNumber(request.PolicyNumber)) { return(new PolicyAccountResponse()); } _dataStore.PolicyAccounts.Add(policy); await _dataStore.CommitChanges(); return(new PolicyAccountResponse()); } }
public void Update(PolicyAccount policyAccount) { documentSession.Update(policyAccount); }
public void Add(PolicyAccount policyAccount) { documentSession.Insert(policyAccount); }
public void Update(PolicyAccount policyAccount) { }
public void Add(PolicyAccount policyAccount) { list.Add(policyAccount.PolicyNumber, policyAccount); }
public void NewlyCreatedAccountIsActive() { var account = new PolicyAccount("A", "A", "C", "C"); Equal(PolicyAccountStatus.Active, account.Status); }