Exemple #1
0
        public Cuenta AbrirCuenta(Cuenta cuenta)
        {
            ResultadoTransaccion resultado = _cuentaMapper.Insert(cuenta);

            if (resultado.IsOk)
            {
                return(TraerCuentas(cuenta.IdCliente));
            }
            else
            {
                throw new Exception("Hubo un error en la petición al servicior. Detalle: " + resultado.Error);
            }
        }
Exemple #2
0
        public int InsertarCuenta(int nrocuenta, string descripcion, float saldo, int idcliente, int id)
        {
            Cuenta c = new Cuenta(nrocuenta, descripcion, saldo, idcliente, id);

            TransactionResult resultado = mapper.Insert(c);

            if (resultado.IsOk)
            {
                return(resultado.Id);
            }
            else
            {
                throw new Exception("Ha habido un erro al crear cuenta" + resultado.Error);
            }
        }
Exemple #3
0
 public void IngresarCuenta(Cuenta cuenta)
 {
     if (!ExisteLaCuenta(cuenta))
     {
         TransactionResult result = mapper.Insert(cuenta);
         if (!result.IsOk)
         {
             throw new Exception("Hubo un error en la petición al servidor. Detalle: " + result.Error);
         }
         else
         {
             RefrescarCache();
         }
     }
     else
     {
         throw new CuentaExistenteException(cuenta.Id);
     }
 }
Exemple #4
0
        public int IngresarCuenta(Cuenta cuenta)
        {
            string validaciones = Reglas(cuenta);

            if (!string.IsNullOrEmpty(validaciones))
            {
                throw new CuentaException(validaciones);
            }
            else
            {
                TransactionResult resultado = CuentaMapper.Insert(cuenta);
                if (resultado.IsOk)
                {
                    RecargarLista();
                    return(resultado.Id);
                }
                else
                {
                    throw new CuentaException(resultado.Error);
                }
            }
        }
Exemple #5
0
 public Cuenta AbrirCuenta(string descripcion, int idCliente)
 {
     if (clienteServicio.Existe(idCliente))
     {
         Cuenta c = new Cuenta();
         c.idCliente   = idCliente;
         c.Descripcion = descripcion;
         TransactionResult t = mapper.Insert(c);
         if (t.IsOk)
         {
             return(Traer(idCliente));
         }
         else
         {
             throw new Exception("Error al abrir la cuenta." + t.Error);
         }
     }
     else
     {
         throw new Exception("El cliente no existe");
     }
 }
Exemple #6
0
        public string ActualizarSaldo(Cuenta cuenta)
        {
            string validaciones = ReglasActualizacion(cuenta);

            if (!string.IsNullOrEmpty(validaciones))
            {
                throw new CuentaException(validaciones);
            }
            else
            {
                TransactionResult resultado = CuentaMapper.Insert(cuenta);
                if (resultado.IsOk)
                {
                    RecargarLista();
                    TransactionResult resultadoMail = EnviarMail(cuenta);
                    return(resultado.Id.ToString() + "Envio de mail: " + resultado.IsOk.ToString());
                }
                else
                {
                    throw new CuentaException(resultado.Error);
                }
            }
        }
Exemple #7
0
        public int NuevaCuenta(int idCliente, float saldoInicial, string descripcion)
        {
            int idCuenta = UltimoIdCuenta + 1;

            do
            {
                idCuenta = idCuenta + 1;
            }while (BuscarCuentaById(idCuenta) != null);

            Cuenta cuenta = new Cuenta(idCuenta, idCliente, _nroCuenta: 0, _descripcion: descripcion, _saldo: saldoInicial, _activo: true);

            TransactionResult result = cuentaMapper.Insert(cuenta);

            if (result.IsOk)
            {
                this.Cuentas.Add(cuenta);
                return(result.Id);
            }
            else
            {
                throw new Exception(string.Format("Ocurrió un error en el servidor: {0}.", result.Error));
            }
        }
Exemple #8
0
        public int IngresarCuenta(string descripcion, int idCliente)
        {
            List <Cuenta> lstCuentas = mapper.TraerTodo();


            Cuenta nuevaCuenta = new Cuenta();

            //nuevaCuenta.NroCuenta = nroCuenta;
            nuevaCuenta.Descripcion = descripcion;
            //nuevaCuenta.Saldo = saldo;
            //nuevaCuenta.FechaApertura = fechaApertura;
            //nuevaCuenta.FechaModificacion = DateTime.Now;
            //nuevaCuenta.Activo = true;
            nuevaCuenta.IdCliente = idCliente;

            //Valido que no tenga cuenta cargada.
            Cuenta cuenta = lstCuentas.FirstOrDefault(x => x.IdCliente == idCliente);

            if (cuenta != null)
            {
                throw new Exception("El cliente ya tiene una cuenta cargada. intente con otro.");
            }
            else
            {
                TransactionResult resultado = mapper.Insert(nuevaCuenta);
                //int nroCuenta = mapper.TraerPorID()
                if (resultado.IsOk)
                {
                    return(resultado.Id);
                }
                else
                {
                    throw new Exception(resultado.Error);
                }
            }
        }