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);
     }
 }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
        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);
        }
示例#9
0
        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());
            }
        }
示例#13
0
 public void Update(PolicyAccount policyAccount)
 {
     documentSession.Update(policyAccount);
 }
示例#14
0
 public void Add(PolicyAccount policyAccount)
 {
     documentSession.Insert(policyAccount);
 }
示例#15
0
 public void Update(PolicyAccount policyAccount)
 {
 }
示例#16
0
 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);
        }