Exemplo n.º 1
0
            public async Task <List <CuentaCorriente> > Handle(Query request, CancellationToken cancellationToken)
            {
                List <CuentaCorriente> ccs = await _repository.GetAllCheckingAccountByBankAccountId(request.IdBankAccount);

                return(ccs);
            }
Exemplo n.º 2
0
            public async Task <AccountProductsViewModel> Handle(Query request, CancellationToken cancellationToken)
            {
                Domain.Models.User user = await _userRepository.FindUserByIdAsync(request.IdUser);

                CuentaBancaria cntBancaria = await _bankAccountRepository.FindBankAccount(request.IdAccount);

                user.CntBancaria = cntBancaria;
                List <CuentaAhorro> SavingAccounts =
                    await _savingAccountRepository.GetAllSavingAccountFromABankAccount(request.IdAccount);

                List <CuentaCorriente> chekingAccounts =
                    await _checkingAccount.GetAllCheckingAccountByBankAccountId(request.IdAccount);

                List <DepositoAPlazo> TimeDepositAccounts =
                    await _timeDepositRepository.getAllTimeDepositByIdBankAccount(request.IdAccount);

                List <DepositoAPlazoDTO> dpDTO =
                    _mapper.Map <List <DepositoAPlazo>, List <DepositoAPlazoDTO> >(TimeDepositAccounts);

                List <CuentaAhorroDTO> cadto = _mapper.Map <List <CuentaAhorro>, List <CuentaAhorroDTO> >(SavingAccounts);

                chekingAccounts = chekingAccounts.Select(checkingAccount =>
                {
                    checkingAccount.Saldo = getRealBalanceFromCheckingAccountById(checkingAccount.Id);
                    return(checkingAccount);
                }).ToList();

                cadto = cadto.Select((dto) =>
                {
                    dto.TasaInteresMensual = GetInteres(dto.Saldo);
                    dto.Ganacias           = CalcularGananciasCuentaAhorro(1, dto.TasaInteresMensual, dto.Saldo);
                    dto.Ganacias           =
                        Double.Parse(String.Format(dto.Ganacias % 1 == 0 ? "{0:0}" : "{0:0.00}", dto.Ganacias));
                    // getting real balance from every account
                    dto.Saldo = getRealBalanceFromSavingAccountById(dto.Id);
                    return(dto);
                }).ToList();

                dpDTO = dpDTO.Select(dto =>
                {
                    dto.Ganacias = CalcularGanancias(dto.CantidadDias, dto.TasaInteres, dto.Cantidad);
                    dto.Ganacias =
                        Double.Parse(String.Format(dto.Ganacias % 1 == 0 ? "{0:0}" : "{0:0.00}", dto.Ganacias));
                    return(dto);
                }).ToList();

                double total = SavingAccounts.Aggregate(0.0, (accum, ahorro) => accum + ahorro.Saldo);

                total += chekingAccounts.Aggregate(0.0, (accum, corriente) => accum + corriente.Saldo);
                total += TimeDepositAccounts.Aggregate(0.0, (accum, plazo) => plazo.Cantidad);

                return(new AccountProductsViewModel()
                {
                    user = user,
                    cuentaBancaria = cntBancaria,
                    CuentasAhorro = cadto,
                    CuentaCorrientes = chekingAccounts,
                    totalAccounts = SavingAccounts.Count + chekingAccounts.Count + TimeDepositAccounts.Count,
                    DepositoAPlazos = dpDTO,
                    total = total
                });
            }