示例#1
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            try
            {
                string  nombreUsuario = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).UserData;
                Usuario usuario       = new UsuarioRepository().Obtener(nombreUsuario);

                HomeView            hv = new HomeView();
                SolicitudRepository sr = new SolicitudRepository();
                VentanaRepository   vr = new VentanaRepository();
                hv.Pendientes = sr.ListarPendientesCM();
                string nombreVista = "Index";
                if (User.IsInRole("RM"))
                {
                    hv.Pendientes = sr.ListarPendientesRM();
                    hv.Aprobados  = sr.ListarAprobadosRM();
                    hv.Ventanas   = vr.Listar();

                    nombreVista = "IndexRM";
                }
                if (User.IsInRole("CM"))
                {
                    hv.Pendientes = sr.ListarPendientesCM();
                    nombreVista   = "IndexCM";
                }
                if (User.IsInRole("Operador"))
                {
                    hv.Pendientes = sr.ListarPendientesOperador(usuario.Id);
                    nombreVista   = "IndexOperador";
                }
                if (User.IsInRole("Ejecutor"))
                {
                    hv.Pendientes = sr.ListarPendientesEjecutor(usuario.Id);
                    nombreVista   = "IndexEjecutor";
                }
                return(View(nombreVista, hv));
            }
            catch (Exception ex)
            {
                return(View("Mensaje", new HomeView {
                    Mensaje = ex.Message
                }));
            }
        }