public ActionResult Deposito(CuentaBancaria c, int id)
        {
            try
            {
                double Deposito;
                Deposito = c.Saldo;
                MovimientoBLL movimientobll = new MovimientoBLL();
                CuentaBLL     cuentaBLL     = new CuentaBLL();
                if (cuentaBLL.ValidarSaldo(c) == false)
                {
                    throw new Exception();
                }

                c = cuentaBLL.ListarCuentas(id);
                cuentaBLL.Deposito(c, Deposito);

                Movimientos Mnuevo = new Movimientos();
                Mnuevo.CuentaBancariaDestino = c.NumeroCuenta;
                Mnuevo.CuentaBancariaOrigen  = c.NumeroCuenta;
                Mnuevo.Saldo = Deposito;
                Mnuevo.Tipo  = "Deposito";
                movimientobll.CrearMovimiento(Mnuevo);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        // GET: Cuenta/Create
        public ActionResult Create()
        {
            CuentaBLL cuentaBLL = new CuentaBLL();

            ViewBag.Tipo = new SelectList(cuentaBLL.buscarTipos(), "Codigo", "Nombre");
            return(View());
        }
        public ActionResult Create(CuentaBancaria c)
        {
            CuentaBLL cuentaBLL = new CuentaBLL();

            ViewBag.Tipo = new SelectList(cuentaBLL.buscarTipos(), "Codigo", "Nombre");
            try
            {
                if (cuentaBLL.ValidarSaldo(c) == false)
                {
                    throw new Exception();
                }

                if (cuentaBLL.ValidarCuenta(c) == true)
                {
                    throw new Exception();
                }

                c.TipoCuentaBancaria = cuentaBLL.buscarTipoCuenta(c.Tipo);
                cuentaBLL.CrearCuenta(c);
                return(RedirectToAction("Index"));
            }
            catch
            {
                ViewBag.Advertencia = "Ya existe el numero de cuenta o saldo invalido";
                return(View());
            }
        }
Example #4
0
        public void Transferencia()
        {
            Boolean            resultado = true;
            double             monto;
            CuentaBancaria     cuentabancariatest2 = new CuentaBancaria();
            CuentaBancaria     cuentabancariatest1 = new CuentaBancaria();
            CuentaBLL          cuentabll           = new CuentaBLL();
            TipoCuentaBancaria tipo = new TipoCuentaBancaria();



            tipo.Codigo = 1;
            monto       = 100;
            cuentabancariatest1.NumeroCuenta       = 1;
            cuentabancariatest1.TipoCuentaBancaria = tipo;
            cuentabancariatest1.Saldo              = 100;
            cuentabancariatest1.Propietario        = "Test1";
            cuentabancariatest2.NumeroCuenta       = 2;
            cuentabancariatest2.TipoCuentaBancaria = tipo;
            cuentabancariatest2.Saldo              = 100;
            cuentabancariatest2.Propietario        = "Test2";


            Assert.AreEqual(cuentabll.Transferencia(cuentabancariatest1, cuentabancariatest2, monto), resultado);
        }
 public ActionResult Delete(int id, CuentaBancaria c)
 {
     try
     {
         CuentaBLL cuentaBLL = new CuentaBLL();
         cuentaBLL.EliminarCuenta(cuentaBLL.ListarCuentas(id));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, CuentaBancaria c)
 {
     try
     {
         CuentaBLL cuentaBLL = new CuentaBLL();
         c.NumeroCuenta = id;
         cuentaBLL.ModificarCuenta(c);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Transferencia(Movimientos t)
        {
            try
            {
                CuentaBLL cuentaBLL = new CuentaBLL();
                if (cuentaBLL.ValidarCuenta(cuentaBLL.ListarCuentas(t.CuentaBancariaOrigen)) == false)
                {
                    throw new Exception();
                }

                if (cuentaBLL.ValidarCuenta(cuentaBLL.ListarCuentas(t.CuentaBancariaDestino)) == false)
                {
                    throw new Exception();
                }

                if (t.CuentaBancariaDestino == t.CuentaBancariaOrigen)
                {
                    throw new Exception();
                }

                if (cuentaBLL.ValidarSaldo(cuentaBLL.ListarCuentas(t.CuentaBancariaOrigen), t.Saldo) == false)
                {
                    throw new Exception();
                }


                if (t.Saldo <= 0)
                {
                    throw new Exception();
                }


                cuentaBLL.Transferencia(cuentaBLL.ListarCuentas(t.CuentaBancariaOrigen), cuentaBLL.ListarCuentas(t.CuentaBancariaDestino), t.Saldo);

                MovimientoBLL movimientobll = new MovimientoBLL();
                Movimientos   Mnuevo        = new Movimientos();
                Mnuevo.CuentaBancariaDestino = t.CuentaBancariaDestino;
                Mnuevo.CuentaBancariaOrigen  = t.CuentaBancariaOrigen;
                Mnuevo.Saldo = t.Saldo;
                Mnuevo.Tipo  = "Transferencia";
                movimientobll.CrearMovimiento(Mnuevo);
                return(RedirectToAction("Index"));
            }
            catch
            {
                ViewBag.Advertencia = "Alguna de las cuentas es invalida o el monto no se puede debitar de la cuenta porque sobrepasa el limite";
                return(View());
            }
        }
Example #8
0
        public void Retiro()
        {
            Boolean            resultado = true;
            double             monto;
            CuentaBancaria     cuentabancariatest = new CuentaBancaria();
            CuentaBLL          cuentabll          = new CuentaBLL();
            TipoCuentaBancaria tipo = new TipoCuentaBancaria();



            tipo.Codigo = 1;
            monto       = 100;
            cuentabancariatest.NumeroCuenta       = 100;
            cuentabancariatest.TipoCuentaBancaria = tipo;
            cuentabancariatest.Saldo       = 100;
            cuentabancariatest.Propietario = "Test";


            Assert.AreEqual(cuentabll.Retiro(cuentabancariatest, cuentabancariatest.Saldo), resultado);
        }
        // GET: Cuenta/Edit/5
        public ActionResult Edit(int id)
        {
            CuentaBLL cuentaBLL = new CuentaBLL();

            return(View(cuentaBLL.ListarCuentas(id)));
        }
        // GET: Cuenta
        public ActionResult Index()
        {
            CuentaBLL cuentaBLL = new CuentaBLL();

            return(View(cuentaBLL.ListarCuentas()));
        }