Exemple #1
0
        private void RecargarLista()
        {
            List <Cuenta> lstCuentas = new List <Cuenta>();

            _lstCliente = ClienteMapper.TraerTodoClientes();
            _lstCuenta  = CuentaMapper.TraerTodo();
            foreach (Cliente a in _lstCliente)
            {
                lstCuentas.AddRange(_lstCuenta.Where(x => x.IdCliente == a.Id).ToList());
            }

            _lstCuenta = lstCuentas;
        }
        //public int ModificarTarjetaCredito(TarjetaCredito tarjeta)
        //{
        //    string reglas = ReglasTarjetaCredito(tarjeta);
        //    if (!string.IsNullOrEmpty(reglas))
        //    {
        //        throw new TarjetaException("Error " + reglas);
        //    }
        //    else
        //    {
        //        TransactionResult resultado = TarjetaCreditoMapper.Update(tarjeta);
        //        if (resultado.IsOk)
        //        {
        //            return resultado.Id;
        //        }
        //        else
        //        {
        //            throw new TarjetaException("Error al modificar tarjeta " + resultado.Error);
        //        }
        //    }
        //}
        //public int EliminarTarjetaCredito(int idTarjeta)
        //{
        //    TransactionResult resultado = TarjetaCreditoMapper.Delete(idTarjeta);
        //    if (resultado.IsOk)
        //    {
        //        return resultado.Id;
        //    }
        //    else
        //    {
        //        throw new TarjetaException("Error al eliminar tarjeta " + resultado.Error);
        //    }
        //}
        private string ReglasTarjetaCredito(TarjetaCredito tarjeta)
        {
            string resultado = "";

            if (_lstTarjetaCredito.Any(x => x.NroPlastico == tarjeta.NroPlastico))
            {
                resultado += "La tarjeta ya se encuentra registrada.\n";
            }
            if (!ClienteMapper.TraerTodoClientes().Any(x => x.Id == tarjeta.IdCliente))
            {
                resultado += "El Cliente no existe.\n";
            }
            if (!CuentaMapper.TraerTodo().Any(x => x.IdCliente == tarjeta.IdCliente))
            {
                resultado += "El Cliente no tiene cuenta.\n";
            }

            return(resultado);
        }
Exemple #3
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 #4
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 #5
0
 public CuentaServicio()
 {
     mapper = new CuentaMapper();
 }
Exemple #6
0
 public TarjetaServicio()
 {
     mapperCuenta = new CuentaMapper();
     mapper       = new TarjetaMapper();
 }
Exemple #7
0
 public CuentaCrudFactory() : base()
 {
     mapper = new CuentaMapper();
     dao    = SqlDao.GetInstance();
 }
Exemple #8
0
 public CuentaServicio()
 {
     this._cuentaMapper = new CuentaMapper();
 }
 public ClienteServicio()
 {
     mapper       = new ClienteMapper();
     mapperCuenta = new CuentaMapper();
 }
 public CuentaServicio()
 {
     mapper          = new CuentaMapper();
     _lstCuentas     = new List <Cuenta>();
     clienteServicio = new ClienteServicio();
 }
 public CuentaServicio()
 {
     mapper          = new CuentaMapper();
     clienteServicio = new ClienteServicio();
 }
Exemple #12
0
 public CuentaServicio()
 {
     mapper = new CuentaMapper();
     RefrescarCache();
 }