示例#1
0
        public async Task InsertTransaccion(Transacciones transacciones)
        {
            var cuenta = await _cuentaAhorroRepository.GetCuentaAhorros(transacciones.NumeroCuenta);

            if (cuenta == null)
            {
                throw new BusinessException("La cuenta de ahorros no existe");
            }
            else if (transacciones.IdTipoTransaccion == 2 && transacciones.Monto > cuenta.Monto)
            {
                throw new BusinessException("El monto a retirar supera el valor  que se tiene en la cuenta");
            }
            else
            {
                Transacciones transaccion = new Transacciones();
                transaccion.NumeroCuenta      = transacciones.NumeroCuenta;
                transaccion.Monto             = transacciones.Monto;
                transaccion.IdTipoTransaccion = transacciones.IdTipoTransaccion;
                transaccion.FechaTransaccion  = DateTime.Now;

                await _cuentaAhorroRepository.UpdateCuentaAhorros(transaccion.NumeroCuenta, Convert.ToDouble(transaccion.Monto), Convert.ToInt32(transaccion.IdTipoTransaccion));

                await _transacionRepository.InsertTransaccion(transaccion);
            }
        }
示例#2
0
 public async Task <CuentaAhorros> GetCuentaAhorros(string numeroCuenta)
 {
     return(await _cuentaAhorroRepository.GetCuentaAhorros(numeroCuenta));
 }