Exemple #1
0
        public void AddAccountsToService(IBankAccountService bankService, IBankAccountFactory accountFactory)
        {
            BankAccount account1 = accountFactory.GetInstance(1, "Khenichi Samura", 0, 0, TypeBankAccount.Base);
            BankAccount account2 = accountFactory.GetInstance(2, "Novik Ilya", 2000, 0, TypeBankAccount.Golden);
            BankAccount account3 = accountFactory.GetInstance(3, "Robert Martin", 0, 0, TypeBankAccount.Golden);

            account3.DepositMoney(1000);

            bankService.Add(account1);
            bankService.Add(account2);
            bankService.Add(account3);

            bankService.Save();
        }
        public void BankAccount_Applications_Add_ShouldBeOk()
        {
            //Arrange
            _bankAccount = ObjectMother.BankAccountWithClientWithId();
            _mockBankAccountRepository.Setup(br => br.Add(_bankAccount)).Returns(_bankAccount);
            _mockClientRepository.Setup(c => c.GetById(_bankAccount.Client.Id)).Returns(_bankAccount.Client);

            //Action
            int addedBankAccountId = _bankAccountService.Add(_bankAccount);

            //Assert
            _mockBankAccountRepository.Verify(br => br.Add(_bankAccount));
            addedBankAccountId.Should().Be(_bankAccount.Id);
        }
        public Task <BaseResponse> Add(BankAccountAddRequest request)
        {
            var response = new BaseResponse();

            TryCatch(() =>
            {
                var bankAccount    = bankAccountService.GetAllBankAccounts();
                var arrBankAccount = bankAccount.Select(x => x.BankAccount).ToArray();
                if (arrBankAccount.Contains(request.BankAccount))
                {
                    throw new ErrorCodeException(ErrorCodeDefine.CHECK_BANK_ACCOUNT);
                }

                var model         = new Bank_Account();
                model.BankAccount = request.BankAccount;
                model.BankName    = request.BankName;
                model.Branch      = request.Branch;
                model.Address     = request.Address;
                model.Province    = request.Province;
                model.Owner       = request.Owner;
                model.Note        = request.Note;
                bankAccountService.Add(model);

                unitOfWork.Commit();

                response.Successful();
            }, response);
            return(Task.FromResult(response));
        }
Exemple #4
0
        public void AddAccountsToService(IBankAccountService bankService, IBankAccountFactory accountFactory)
        {
            var generatorId = this.kernel.Get <IGeneratorId>();

            BankAccount account1 = accountFactory.GetInstance(generatorId.GenerateId(0), "Khenichi Samura", 0, 0, TypeBankAccount.Base);
            BankAccount account2 = accountFactory.GetInstance(generatorId.GenerateId(1), "Novik Ilya", 2000, 0, TypeBankAccount.Golden);
            BankAccount account3 = accountFactory.GetInstance(generatorId.GenerateId(2), "Robert Martin", 0, 0, TypeBankAccount.Golden);

            account3.DepositMoney(1000);

            bankService.Add(account1);
            bankService.Add(account2);
            bankService.Add(account3);

            bankService.Save();
        }
Exemple #5
0
        public void AddAccountsToService(IBankAccountService bankService, BankAccountBuilder accountBuilder)
        {
            BankAccount account1 = accountBuilder.Create("Hiroshi Nakmura", 370000, 1000, Status.Close, BankAccountTypes.Prime);
            BankAccount account2 = accountBuilder.Create("Ilon Mask", 2000000, 35000, Status.Open, BankAccountTypes.Silver);
            BankAccount account3 = accountBuilder.Create("Inkognito man", 22500, 1000, Status.Waiting, BankAccountTypes.Gold);
            BankAccount account4 = accountBuilder.Create("Kondratovich Maxim", 2555000, 58000, Status.Open, BankAccountTypes.Platinum);

            account1.Deposite(2500);
            account4.Deposite(5000);
            account2.Withdraw(1100);
            account3.Withdraw(2250);

            bankService.Add(account1);
            bankService.Add(account2);
            bankService.Add(account3);
            bankService.Add(account4);
            bankService.Deactivate(account1, Status.Waiting);
        }
Exemple #6
0
        public ActionResult <string> Post(JsonElement value)
        {
            try
            {
                string json        = System.Text.Json.JsonSerializer.Serialize(value);
                var    getRealdata = JsonConvert.DeserializeObject <BankAccount>(json);

                var getReturn = _bankAccount.Add(getRealdata);

                return("saved with success!");
            }
            catch (Exception ex)
            {
                return(Problem(detail: ex.StackTrace, title: ex.Message));
            }
        }
        public IActionResult Post()
        {
            Customer customer = customerService.Get(User.Identity.Name);

            int totalCount    = bankAccountService.TotalCount(customer.No);
            int bankAccountNo = totalCount + 1001;

            BankAccount bankAccount = new BankAccount();

            bankAccount.CustomerNo = customer.No;
            bankAccount.IsActive   = true;
            bankAccount.Balance    = 0.0m;
            bankAccount.No         = bankAccountNo;
            bankAccount.Date       = DateTime.Now;

            bankAccountService.Add(bankAccount);

            return(Ok(new { status = "success", bankAccount.No, bankAccount.Balance, createdDate = bankAccount.Date }));
        }
 public IHttpActionResult Add(BankAccount bankAccount)
 {
     return(HandleCallback(() => _bankAccountsService.Add(bankAccount)));
 }
Exemple #9
0
        public IActionResult Create(CreateBankAccountDto createBankAccountDto)
        {
            var bankAccount = _bankAccountService.Add(createBankAccountDto);

            return(CreatedAtAction(nameof(Get), new { id = bankAccount.Id }, bankAccount));
        }