예제 #1
0
        public ConsignarResponse Ejecutar(ConsignarRequest request)
        {
            var cuenta = _unitOfWork.FinancialServiceRepository.FindBy(t => t.Number == request.AccountNumber, includeProperties: "Transactions").FirstOrDefault();

            if (cuenta == null)
            {
                return new ConsignarResponse {
                           Message = $"Error: Número de Cuenta {request.AccountNumber} No Válido."
                }
            }
            ;
            try
            {
                cuenta.Income(new Transaction {
                    Amount = request.Amount
                });

                _unitOfWork.Commit();
                return(new ConsignarResponse()
                {
                    Message = $"Su Nuevo saldo es {cuenta.Balance}."
                });
            }
            catch (InvalidOperationException ex)
            {
                return(new ConsignarResponse()
                {
                    Message = ex.Message
                });
            }
        }
    }
예제 #2
0
        public void RetirarCuentaAhorroTest()
        {
            //Creacion
            var createRequest = new CrearCuentaBancariaRequest {
                Numero = "1113", Nombre = "aaaaa", TipoCuenta = "Ahorro"
            };
            CrearCuentaBancariaService _createService = new CrearCuentaBancariaService(new UnitOfWork(_context));

            _createService.Ejecutar(createRequest);

            //Consignacion
            ConsignarService _consignarService = new ConsignarService(new UnitOfWork(_context));
            var consignarRequest = new ConsignarRequest {
                NumeroCuenta = "1113", Ciudad = "Valledupar", Valor = 100000
            };

            _consignarService.Ejecutar(consignarRequest);

            //Retiro
            RetirarService _retirarService = new RetirarService(new UnitOfWork(_context));
            var            retirarRequest  = new RetirarRequest {
                NumeroCuenta = "1113", Valor = 50000
            };

            var retirarResponse = _retirarService.Ejecutar(retirarRequest);

            Assert.AreEqual($"Su Nuevo saldo es 50000.", retirarResponse.Mensaje);
        }
예제 #3
0
        public ActionResult <ConsignarResponse> Post(ConsignarRequest request)
        {
            var _service = new ConsignarService(new UnitOfWork(_context));
            var response = _service.Ejecutar(request);

            return(Ok(response));
        }
        public void ConsignTest(string numeroCuenta, double valor, string ciudadDeConsignacion, string esperado)
        {
            var request = new ConsignarRequest {
                NumeroCuenta = numeroCuenta, CiudadDeConsignacion = ciudadDeConsignacion, Valor = valor
            };
            ConsignarService _service = new ConsignarService(new UnitOfWork(_context));
            var    response           = _service.Ejecutar(request);
            string obtenido           = response.Mensaje.Contains(esperado) ? esperado : response.Mensaje;

            Assert.AreEqual(esperado, obtenido);
        }
        public IHttpActionResult Post(ConsignarRequest request)
        {
            ConsignarService _service = new ConsignarService(new UnitOfWork(_db), new CuentaBancariaRepository(_db));

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var response = _service.Ejecutar(request);

            return(Ok(response));
        }
예제 #6
0
        private static void ConsignarCuentaBancaria(BancoContext context)
        {
            ConsignarService _service = new ConsignarService(new UnitOfWork(context));
            var request = new ConsignarRequest()
            {
                AccountNumber = "524255", Amount = 1000
            };

            ConsignarResponse response = _service.Ejecutar(request);

            System.Console.WriteLine(response.Message);
            System.Console.ReadKey();
        }
        public void TestConsignarCorriente()
        {
            //Arrange
            ConsignarService _service = new ConsignarService(_unitOfWork, _repositoryCuentaBancaria);
            var request = new ConsignarRequest()
            {
                NumeroCuenta = "524256", Valor = 1000
            };
            //Act
            ConsignarResponse response = _service.Ejecutar(request);

            //Assert
            Assert.AreEqual($"Su Nuevo saldo es 1000.", response.Mensaje);
        }
예제 #8
0
        public void ConsignarCuentaBancaria()
        {
            var cuenta = new CrearCuentaBancariaRequest {
                Numero = "1215", Nombre = "aaaaa", TipoCuenta = "Ahorro", Ciudad = "Valledupar"
            };
            CrearCuentaBancariaService _service = new CrearCuentaBancariaService(new UnitOfWork(_context));
            var response1 = _service.Ejecutar(cuenta);
            var request   = new ConsignarRequest {
                Numero = "1215", Valor = 100000, Ciudad = "Valledupar"
            };
            ConsignarService _service1 = new ConsignarService(new UnitOfWork(_context));
            var response = _service1.Ejecutar(request, "CuentaBancaria");

            Assert.AreEqual("Su Nuevo saldo es 100000.", response.Mensaje);
        }
예제 #9
0
        public void ZAbonnarCredito()
        {
            var request = new CrearCreditoRequest {
                Cedula = "1111", ValorPrestamo = 5000000, Nombre = "fabian", Salario = 1200000, PlazoPago = 4, TipoCredito = 0, Fecha = DateTime.Now
            };
            CrearPrestamoService _service2 = new CrearPrestamoService(new UnitOfWork(_context));
            var response = _service2.Ejecutar(request);
            ConsignarService _service = new ConsignarService(new UnitOfWork(_context));
            var request3 = new ConsignarRequest {
                Cedula = "1111", Fecha = DateTime.Now, Valor = 3850000
            };
            //se realizan 2 avonos por un valor de 7700000
            InvalidOperationException ex2 = Assert.Throws <InvalidOperationException>(() => _service.Ejecutar(request3));

            Assert.AreEqual(ex2.Message, "abonado con exito en las cuotas con indicador 1111 usted debe 11150000");
        }
예제 #10
0
        private static void Abonar(BancoContext context)
        {
            #region  Consignar

            ConsignarService _service = new ConsignarService(new UnitOfWork(context));
            var request = new ConsignarRequest()
            {
                Cedula = "524255", Valor = 1000000, Fecha = DateTime.Now
            };

            ConsignarResponse response = _service.Ejecutar(request);

            System.Console.WriteLine(response.Mensaje);
            #endregion
            System.Console.ReadKey();
        }
예제 #11
0
        public void ConsignarCuentaCorrienteTest()
        {
            var createRequest = new CrearCuentaBancariaRequest {
                Numero = "10002", Nombre = "Cuenta Ejemplo", TipoCuenta = "Corriente"
            };
            CrearCuentaBancariaService _createService = new CrearCuentaBancariaService(new UnitOfWork(_context));
            var createResponse = _createService.Ejecutar(createRequest);

            ConsignarService _consignarService = new ConsignarService(new UnitOfWork(_context));
            var consignarRequest = new ConsignarRequest {
                NumeroCuenta = "10002", Ciudad = "Valledupar", Valor = 100000
            };
            var consignarResponse = _consignarService.Ejecutar(consignarRequest);

            Assert.AreEqual($"Su Nuevo saldo es {consignarRequest.Valor}.", consignarResponse.Mensaje);
        }
예제 #12
0
        private static void ConsignarCuentaBancaria(BancoContext context)
        {
            #region  Consignar

            ConsignarService _service = new ConsignarService(new UnitOfWork(context));
            var request = new ConsignarRequest()
            {
                NumeroCuenta = "524255", Valor = 1000
            };

            ConsignarResponse response = _service.Ejecutar(request);

            System.Console.WriteLine(response.Mensaje);
            #endregion
            System.Console.ReadKey();
        }
예제 #13
0
        public void ConsignarCDTTest()
        {
            var FechaDeInicio  = new DateTime(2020, 2, 4);
            var FechaDeTermino = new DateTime(2020, 3, 4); //Año Mes Dia
            var request        = new CrearDepositoATerminoRequest {
                Numero = "1111", Nombre = "aaaaa", FechaDeInicio = FechaDeInicio, FechaDeTermino = FechaDeTermino, TasaInteres = 0.2, Ciudad = "Valledupar"
            };
            CrearDepositoATerminoService _service = new CrearDepositoATerminoService(new UnitOfWork(_context));
            var response = _service.Ejecutar(request);
            var request1 = new ConsignarRequest {
                Numero = "1111", Valor = 1000000, Ciudad = "Valledupar"
            };
            ConsignarService _service1 = new ConsignarService(new UnitOfWork(_context));
            var response2 = _service1.Ejecutar(request1, "CDT");

            Assert.AreEqual("Su Nuevo saldo es 1000000.", response2.Mensaje);
        }
예제 #14
0
        public void CrearConsignarCuentaCorrienteTest()
        {
            var request = new CrearCuentaBancariaRequest {
                Numero = "2111", Nombre = "aaaaa", TipoCuenta = "Corriente"
            };
            CrearCuentaBancariaService _service = new CrearCuentaBancariaService(new UnitOfWork(_context));
            var response = _service.Ejecutar(request);

            Assert.AreEqual("Se creó con éxito la cuenta 2111.", response.Mensaje);

            var requestConsignar = new ConsignarRequest {
                NumeroCuenta = "2111", Valor = 100000
            };
            var serviceConsignar  = new ConsignarService(new UnitOfWork(_context));
            var responseConsignar = serviceConsignar.Ejecutar(requestConsignar);

            Assert.AreEqual($"Su Nuevo saldo es {requestConsignar.Valor}.", responseConsignar.Mensaje);
        }
        public void TestTrasaldar()
        {
            //Arrange
            ConsignarService _serviceConsignar = new ConsignarService(_unitOfWork, _repositoryCuentaBancaria);
            var requestConsignar = new ConsignarRequest()
            {
                NumeroCuenta = "524255", Valor = 5000
            };

            _serviceConsignar.Ejecutar(requestConsignar);

            TrasladarService _service = new TrasladarService(_unitOfWork, _repositoryCuentaBancaria);
            var request = new TrasladarRequest()
            {
                NumeroCuenta = "524255", Valor = 1000, NumeroCuentaDestino = "524256"
            };
            //Act
            TrasladarResponse response = _service.Ejecutar(request);

            //Assert
            Assert.AreEqual($"Su nuevo saldo es 4000.", response.Mensaje);
        }
예제 #16
0
        public void ConsignarCuentaCreditoTest()
        {
            var createRequest = new CrearCuentaBancariaRequest {
                Numero = "10003", Nombre = "Cuenta Ejemplo", TipoCuenta = "Credito"
            };
            CrearCuentaBancariaService _createService = new CrearCuentaBancariaService(new UnitOfWork(_context));
            var createResponse = _createService.Ejecutar(createRequest);

            RetirarService _retirarService = new RetirarService(new UnitOfWork(_context));
            var            retirarRequest  = new RetirarRequest {
                NumeroCuenta = "10003", Valor = 300000
            };
            var retirarResponse = _retirarService.Ejecutar(retirarRequest);

            ConsignarService _consignarService = new ConsignarService(new UnitOfWork(_context));
            var consignarRequest = new ConsignarRequest {
                NumeroCuenta = "10003", Ciudad = "Valledupar", Valor = 200000
            };
            var consignarResponse = _consignarService.Ejecutar(consignarRequest);

            Assert.AreEqual($"Su Nuevo saldo es 900000.", consignarResponse.Mensaje);
        }
 public ActionResult<ConsignarResponse> Post(ConsignarRequest request)
 {
     var _service = new ConsignarService(_unitOfWork);
     var response = _service.Ejecutar(request);
     return Ok(response);
 }