static void Main(string[] args)
        {
            DateTime FechInicio;
            DateTime FechFinal;
            double   Pago = 0, Dia = 15;

            Console.WriteLine("Bienvenido a Miguel's Cars");
            Console.WriteLine("Favor ingrese la fecha en que incio el alquiler del vehiculo");
            FechInicio = Convert.ToDateTime(Console.ReadLine());
            Console.WriteLine("Favor ingrese la fecha de la devolucion del vehiculo");
            FechFinal = Convert.ToDateTime(Console.ReadLine());
            Console.WriteLine("El precio diario sera de : {0}", Dia.ToString("C2"));
            Pago = Dia * FechFinal.Subtract(FechInicio).Days;
            Console.WriteLine("Inicio del alquiler del vehiculo: ");
            Console.WriteLine(FechInicio.ToString("dd/MM/yyyy"));
            Console.WriteLine("Devolucion del vehiculo: ");
            Console.WriteLine(FechFinal.ToString("dd/MM/yyyy"));
            Console.WriteLine(FechFinal.Subtract(FechInicio).Days + " Dias ");
            Console.WriteLine("El total a pagar por el alquiler es de : {0}", Pago.ToString("C2"));
            Console.ReadKey();
        }
        // GET: Inicio
        public ActionResult Index(int?id, int?rango)
        {
            Dashboard miDashboard = new Dashboard();
            DateTime  Fecha, FechInicial, FechFinal;

            Fecha = DateTime.Today;
            bool FiltrarxCuenta            = true;
            List <tmovimiento> Movimientos = new List <tmovimiento>();

            try
            {
                //Actulizo valores de los filtros
                if ((id != null && Sesion.Cuentas.Any(c => c.Id == id)) || id == 0)
                {
                    Sesion.CuentaFiltro = Convert.ToInt16(id);
                }
                if (rango == null)
                {
                    rango = Sesion.RangoFiltro;
                }


                Sesion.RangoFiltro = Convert.ToInt16(rango);
                if (Sesion.CuentaFiltro == 0)
                {
                    FiltrarxCuenta       = false;
                    ViewBag.CuentaFiltro = 0;
                }
                else
                {
                    ViewBag.CuentaFiltro = Sesion.CuentaFiltro;
                }
                // Filtro por fecha 1= Dia 2=Semana 3=Mes 4=Ano 5=Rango
                switch (rango)
                {
                case 1:
                {
                    ViewBag.Rango       = "Movimientos del día ";
                    ViewBag.RangoFiltro = Fecha.ToString("dd/MM/yyyy");
                    rango = 1;         // Se valida el parametro
                    if (FiltrarxCuenta)
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha.Day == Fecha.Day &&
                                                             m.Fecha.Month == Fecha.Month &&
                                                             m.Fecha.Year == Fecha.Year &&
                                                             m.Id_Cuenta == Sesion.CuentaFiltro).Include(c => c.tcuenta).ToList();
                    }
                    else
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha.Day == Fecha.Day &&
                                                             m.Fecha.Month == Fecha.Month &&
                                                             m.Fecha.Year == Fecha.Year).Include(c => c.tcuenta).ToList();
                    }
                    break;
                }

                case 2:
                {
                    if (TempData.ContainsKey("FiltroFecha"))
                    {
                        ViewBag.Rango = "Rango de Fechas";
                        ReporteFeha rangoFeha = (ReporteFeha)TempData["FiltroFecha"];
                        FechInicial = rangoFeha.FecFinal;
                        FechFinal   = rangoFeha.FecFinal.AddHours(23.9999);
                    }
                    else
                    {
                        ViewBag.Rango = "Semana Actual";
                        // lastMonday is always the Monday before nextSunday. When date is a
                        // Sunday, lastMonday will be tomorrow.
                        int offset = Fecha.DayOfWeek - DayOfWeek.Monday;
                        FechInicial = Fecha.AddDays(-offset);
                        FechFinal   = Fecha.AddDays(7 - (int)Fecha.DayOfWeek).AddHours(23.9999);
                    }
                    ViewBag.RangoFiltro = FechInicial.ToString("dd/MM/yyyy") + " hasta " + FechFinal.ToString("dd/MM/yyyy");
                    if (FiltrarxCuenta)
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha >= FechInicial && m.Fecha <= FechFinal && m.Id_Cuenta == Sesion.CuentaFiltro).Include(c => c.tcuenta).ToList();
                    }
                    else
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha >= FechInicial && m.Fecha <= FechFinal).Include(c => c.tcuenta).ToList();
                    }

                    break;
                }

                case 4:
                {
                    ViewBag.Rango       = "Año Actual";
                    ViewBag.RangoFiltro = Fecha.Year;
                    if (FiltrarxCuenta)
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha.Year == Fecha.Year &&
                                                             m.Id_Cuenta == Sesion.CuentaFiltro).Include(c => c.tcuenta).ToList();
                    }
                    else
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha.Year == Fecha.Year).Include(c => c.tcuenta).ToList();
                    }
                    break;
                }

                case 5:
                {
                    ViewBag.Rango       = "Lista";
                    ViewBag.RangoFiltro = "Todos los movimientos";
                    if (FiltrarxCuenta)
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Id_Cuenta == Sesion.CuentaFiltro).Include(c => c.tcuenta).ToList();
                    }
                    else
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id).Include(c => c.tcuenta).ToList();
                    }
                    break;
                }

                default:
                {
                    ViewBag.Rango       = "Mes Actual";
                    ViewBag.RangoFiltro = Fecha.Month + " del " + Fecha.Year;
                    if (FiltrarxCuenta)
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha.Month == Fecha.Month &&
                                                             m.Fecha.Year == Fecha.Year &&
                                                             m.Id_Cuenta == Sesion.CuentaFiltro).Include(c => c.tcuenta).ToList();
                    }
                    else
                    {
                        Movimientos = db.tmovimientoes.Where(m => m.Id_Usuario == Sesion.Usuario.Id &&
                                                             m.Fecha.Month == Fecha.Month &&
                                                             m.Fecha.Year == Fecha.Year).Include(c => c.tcuenta).ToList();
                    }
                    break;
                }
                }
                miDashboard.Categorias  = Movimientos.Select(c => c.tcategoria).Distinct().ToList();
                miDashboard.Monedas     = Movimientos.Select(c => c.tcuenta.tmoneda).Distinct().ToList();
                miDashboard.Movimientos = Movimientos.OrderByDescending(c => c.Id).ToList();
                miDashboard.Cuentas     = Movimientos.Select(c => c.tcuenta).Distinct().ToList();
            }
            catch
            {
                AddMsgWeb("Error crítico al acceder a los datos", ToastType.Error);
            }
            return(View(miDashboard));
        }