예제 #1
0
        public async Task AddBankAccount_Test()
        {
            var bankModel = new CreateBankAccountModel {
                AccountType    = 1,
                InitialDeposit = 20.00m
            };

            var _efCoreMock = new Mock <IRepository>();

            _efCoreMock.Setup(x => x.Add <BankAccount>(It.IsAny <BankAccount>()));
            var userStore = new Mock <IUserStore <Customer> >();

            var _customerManagerMock = new Mock <UserManager <Customer> >(
                userStore.Object, null, null, null, null, null, null, null, null);

            var _mapperMock    = new Mock <IMapper>();
            var bankController = new BankAccountController(_efCoreMock.Object,
                                                           _customerManagerMock.Object,
                                                           _mapperMock.Object);
            //_efCoreMock.SetupGet(x => x.HttpContext.User.Identity.Name);
            var response = await bankController.CreateAccount(bankModel);

            var ok = response as OkObjectResult;

            Assert.Equal(201, ok.StatusCode);
        }
예제 #2
0
        public ActionResult CreateBankAccount()
        {
            var model = new CreateBankAccountModel()
            {
                IsRejected = false
            };

            return(View(model));
        }
예제 #3
0
        public async Task <IActionResult> CreateAccount(CreateBankAccountModel model)
        {
            var customerId  = User.Identity.Name;
            var bankAccount = await _bankRepo.CreateAccount(model, customerId);

            var bankModel = _mapper.Map <BankAccountModel>(bankAccount);

            await _repo.Add(bankAccount);

            return(Ok(bankAccount));
        }
예제 #4
0
        public async Task <ActionResult> RejectBankAccount()
        {
            var withdrawalData = await GetMemberApiProxy(Request).GetWithdrawalFormDataAsync(new AppSettings().BrandId);

            var model = new CreateBankAccountModel()
            {
                IsRejected = true,
                Remark     = withdrawalData.BankAccount.Remark
            };

            return(View("CreateBankAccount", model));
        }
        public async Task <BankAccount> CreateAccount(CreateBankAccountModel model, string customerId)
        {
            var user = await _userManager.FindByIdAsync(customerId);

            var customer = await _repo.GetWithWhere <Customer>(o => o.UserId == user.Id);

            var bankAccountType = await _repo.GetById <BankAccountType>(model.AccountType);

            if (customer == null || bankAccountType == null)
            {
                throw new AppException("Unavailable user");
            }

            var bankAccountName = await CreateBankAccount.GenerateBankAccountNumber(bankAccountType.Code, customer);

            var balance        = model.InitialDeposit;
            var initialDeposit = model.InitialDeposit;
            var maintenanceFee = bankAccountType.MaintenanceFee;
            var interestRate   = bankAccountType.InitialInterestRate ?? 0;

            DateTime?lastDeposit;

            if (initialDeposit > 0)
            {
                lastDeposit = DateTime.Now;
            }
            else
            {
                lastDeposit = null;
            }

            var bankAccount = new BankAccount {
                AccountNumber     = bankAccountName,
                Balance           = balance,
                MaintenanceFee    = maintenanceFee,
                InterestRate      = interestRate,
                InitialDeposit    = initialDeposit,
                LastDeposit       = lastDeposit,
                BankAccountStatus = BankAccountStatus.Active,
                AccountType       = bankAccountType,
                Customer          = customer
            };

            return(bankAccount);
        }
예제 #6
0
        public async Task <IActionResult> CreateLoan([FromBody] CreateLoanModel model)
        {
            var loan = await _repo.GetByIdWithInclude <Loan>(model.LoanId, o => o.LoanType);

            var customer = await _repo.GetWithWhere <Customer>(o => o.CNP == model.CustomerCNP);

            var create_model = new CreateBankAccountModel
            {
                AccountType    = 4,
                InitialDeposit = 10000,
            };
            var bankAccount = await _bankRepo.CreateAccount(create_model, customer.UserId.ToString());

            bankAccount.InterestRate = loan.InterestRate;
            bankAccount.Period       = loan.Period;
            var bank = await _repo.Add <BankAccount>(bankAccount);

            return(Ok(bank));
        }