public static int SaveBankAccountInfo(IBankAccountService _bas, int clientId, string bankName, string bankAccountNumber)
        {
            var bank        = _bas.GetBank(bankName);
            var bankAccount = _bas.Create();

            bankAccount.Account_HolderID = clientId;

            if (bank != null)
            {
                bankAccount.BankID = bank.ID;
            }
            else
            {
                bank      = _bas.CreateBank();
                bank.Name = bankName;
                try
                {
                    bankAccount.BankID = _bas.AddBank(bank);
                }
                finally { }
            }

            bankAccount.Account_Number = bankAccountNumber;


            return(_bas.AddBankAccountInfo(bankAccount));
        }
Ejemplo n.º 2
0
        public IActionResult Post([FromBody] BankAccountDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Ok(_bankAccountService.Create(User.Identity.GetUserId(), User.Identity.Name, model)));
        }
Ejemplo n.º 3
0
        public async void IsBankAccountCreatePossible()
        {
            var form = new BankAccountForm()
            {
                Iban    = "",
                Balance = 100.01,
                UserId  = 100
            };
            var result = await _bankAccountService.Create(form);

            Assert.NotEqual(0, result);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(BankAccountDto bankAccountDto)
        {
            await bankAccountService.ValidateBankAccount(bankAccountDto);

            if (ModelState.IsValid && bankAccountDto.IsValidBankAccount)
            {
                await bankAccountService.Create(bankAccountDto);

                return(RedirectToAction("Index"));
            }

            return(View(bankAccountDto));
        }
Ejemplo n.º 5
0
        public IActionResult Post([FromHeader(Name = "username")] string userName, CreateBankAccountDto toCreateBankAccount)
        {
            Guid createdBankAccountid;

            using (var context = _contextFactory.CreateContext())
            {
                createdBankAccountid = _service.Create(context, userName, toCreateBankAccount);
            }

            var currentUrl = UriHelper.GetDisplayUrl(Request);

            return(Created($"{currentUrl}/{createdBankAccountid}", null));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create(BankAccountForm bankAccount)
        {
            var viewModel = new BankAccountListViewModel();

            try
            {
                await _bankAccountService.Create(bankAccount);

                viewModel.BankAccounts = await _bankAccountService.GetAll();
            }
            catch (Exception e)
            {
                viewModel.Error = new Shared.Models.GackoError(e);
            }
            return(View("Index", viewModel));
        }
Ejemplo n.º 7
0
 public async Task <IActionResult> Create(CreateBankAccountVM accountVM)
 {
     try
     {
         return(new ObjectResult
                    (await _transactionScoped.ExecuteScoped(delegate { return _bankAccountService.Create(accountVM.CustomerID, accountVM.InitialCredit); })));
     }
     catch (Exception ex)
     {
         _logger.LogCritical(ex.Message());
         return(new ObjectResult($"{nameof(Create)}-{nameof(BankAccountController)} request failed.")
         {
             StatusCode = StatusCodes.Status500InternalServerError
         });
     }
 }
Ejemplo n.º 8
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer           testServer = new TestServer(builder);
            var                  client     = new ApiClient(testServer.CreateClient());
            ApplicationDbContext context    = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            IBankAccountService service = testServer.Host.Services.GetService(typeof(IBankAccountService)) as IBankAccountService;
            var model = new ApiBankAccountServerRequestModel();

            model.SetProperties("B", 1, "B");
            CreateResponse <ApiBankAccountServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.BankAccountDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiBankAccountServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }