//public ods_interesado Interesado { get; set; } //public HelperController() //{ // //this.Interesado = this.ObtenerInteresado(); //} public ods_interesado ObtenerInteresado() { ods_interesado ods_interesado = null; try { ViewBag.Interesado = null; ViewBag.Mensaje = "Debe iniciar sesión."; if (Session == null) { return(ods_interesado); } if (Session["ods_interesado"] != null) { ods_interesado = (ods_interesado)Session["ods_interesado"]; ods_interesado.ods_municipio = db.ods_municipio.Find(ods_interesado.IdMunicipio); ods_interesado.ods_seguimiento_tarea = db.ods_seguimiento_tarea.SqlQuery(string.Format("select * from dbo.ods_seguimiento tarea where IdInteresado = {0}", ods_interesado.IdInteresado)).ToList(); //ViewBag.Interesado = ods_interesado; //ViewBag.Mensaje = string.Empty; } //this.Interesado = this.ObtenerInteresado(); } catch (Exception /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Debe iniciar sesión."); } return(ods_interesado); }
public ActionResult Autenticar([Bind(Include = "Usuario,Contrasenia")] ods_interesado ods_interesado) { ods_interesado ods_interesado_existe = null; int resultado = 0; string mensaje = "Usuario o Contraseña Incorrectos..."; resultado = ValidarAcceso(ods_interesado.Usuario, ods_interesado.Contrasenia, out ods_interesado_existe); if (resultado == 200) { ViewBag.Mensaje = string.Format("Bienvenido {0}", ods_interesado_existe.Nombre); return(RedirectToAction("Index", "ods_tablero_indicador_ods_vw")); } else if (resultado == 401) { mensaje = "Usuario o Contraseña Incorrectos..."; } else if (resultado == 403) { mensaje = "Su usuario se encuentra inactivo, favor de contactar a su administrador."; } else if (resultado == 307) { mensaje = "Su usuario se encuentra bloqueado, favor de contactar a su administrador."; } //ViewBag.Mensaje = mensaje; ModelState.AddModelError("", mensaje); return(View(ods_interesado)); }
// GET: ods_meta_municipio/Create public ActionResult Create() { int?idMunicipio = null; if (Session["ods_interesado"] != null) { ods_interesado interesado = (ODS.DataLayer.ods_interesado)Session["ods_interesado"]; idMunicipio = interesado.IdMunicipio; } if (idMunicipio == null) { ViewBag.IdIndicador = new SelectList(db.ods_indicador.Where(i => i.Vigente == true).OrderBy(i => i.Indicador).ToList(), "IdIndicador", "Indicador"); ViewBag.IdObjetivoMunicipio = new SelectList(db.ods_objetivo_municipio.OrderBy(o => o.ObjetivoMunicipio).Where(o => o.Vigente == true).ToList(), "IdObjetivoMunicipio", "ObjetivoMunicipio"); } else { ViewBag.IdIndicador = new SelectList(db.ods_indicador.Where(i => i.Vigente == true && i.IdMunicipio == idMunicipio).OrderBy(i => i.Indicador).ToList(), "IdIndicador", "Indicador"); ViewBag.IdObjetivoMunicipio = new SelectList(db.ods_objetivo_municipio.Where(o => o.Vigente == true && o.IdMunicipio == idMunicipio).OrderBy(o => o.ObjetivoMunicipio).ToList(), "IdObjetivoMunicipio", "ObjetivoMunicipio"); } List <SelectListItem> lstAnio = new List <SelectListItem>(); for (int valor = DateTime.Now.Year - 1; valor <= 2050; valor++) { SelectListItem item = new SelectListItem(); item.Text = string.Format("{0:0}", valor); item.Value = string.Format("{0:0}", valor); lstAnio.Add(item); } ViewBag.ListaAnios = new SelectList(lstAnio, "Value", "Text"); return(View()); }
public ActionResult DeleteConfirmed(int id) { ods_interesado ods_interesado = db.ods_interesado.Find(id); db.ods_interesado.Remove(ods_interesado); db.SaveChanges(); return(RedirectToAction("Index")); }
private int ValidarAcceso(string pUsuario, string pPassword, out ods_interesado ods_interesado) { int resultado = 400; string hash_password = string.Empty; IQueryable <ods_interesado> ods_Interesado_encontrado = null; ods_interesado = null; try { hash_password = Cifrar(pPassword); ods_Interesado_encontrado = from p in db.ods_interesado where (pUsuario.Trim().ToLower() == p.Usuario.ToLower()) select p; if (ods_Interesado_encontrado != null) { ods_interesado = ods_Interesado_encontrado.First(); if (ods_interesado.Contrasenia.Trim() == hash_password.Trim()) { if (!ods_interesado.Activo) { resultado = 403; } else if (ods_interesado.Bloqueado) { resultado = 307; } else { //Actualizar los datos de sesión. ods_interesado.UltimaSesion = DateTime.Now; ods_interesado.IPUltimaSesion = (string)Session["ip"]; db.Entry(ods_interesado).State = EntityState.Modified; db.SaveChanges(); ods_interesado.ods_municipio = db.ods_municipio.Find(ods_interesado.IdMunicipio); ods_interesado.ods_seguimiento_tarea = db.ods_seguimiento_tarea.SqlQuery(string.Format("select * from dbo.ods_seguimiento_tarea where IdInteresado = {0}", ods_interesado.IdInteresado)).ToList(); ods_interesado.ods_tarea = db.ods_tarea.SqlQuery(string.Format("select * from dbo.ods_tarea where IdInteresado = {0}", ods_interesado.IdInteresado)).ToList(); Session["ods_interesado"] = ods_interesado; FormsAuthentication.SetAuthCookie(ods_interesado.Usuario, false); resultado = 200; } } } } catch (Exception ex) { ViewBag.Mensaje = "Error: Usuario o Contraseña Incorrecta."; ViewBag.Debug = ex.ToString(); } return(resultado); }
public ActionResult CerrarSesion(ods_interesado model) { //this.GuardarEvento("Cierre de Sesión", "Salida del Sistema", string.Format("El Usuario: {0} ha finalizado su sesión en control de acceso.", Session["usuario"])); //ViewBag.NombreCompleto = String.Empty; Session["ods_interesado"] = null; ViewBag.Mensaje = "Ha cerrado su sesión correctamente."; FormsAuthentication.SignOut(); return(RedirectToAction("Autenticar", "Login")); }
// GET: ods_municipio/Create public ActionResult Create() { ods_interesado ods_interesado = null; if ((ods_interesado = this.ObtenerInteresado()) == null) { return(RedirectToAction("Autenticar", "Login")); } ViewBag.Interesado = ods_interesado; ViewBag.IdEstado = new SelectList(db.ods_estado, "IdEstado", "Estado"); return(View()); }
// GET: ods_municipio public ActionResult Index() { ods_interesado ods_interesado = null; var ods_municipio = db.ods_municipio.Include(o => o.ods_estado); if ((ods_interesado = this.ObtenerInteresado()) == null) { return(RedirectToAction("Autenticar", "Login")); } ViewBag.Interesado = ods_interesado; return(View(ods_municipio.ToList())); }
// GET: ods_interesado/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ods_interesado ods_interesado = db.ods_interesado.Find(id); if (ods_interesado == null) { return(HttpNotFound()); } return(View(ods_interesado)); }
public ActionResult Create([Bind(Include = "IdInteresado,Interesado,Nombre,Usuario,Contrasenia,CorreoRecuperacion,UltimaSesion,IPUltimaSesion,Administrador,SuperUsuario,Bloqueado,Activo,IdMunicipio")] ods_interesado ods_interesado) { if (ModelState.IsValid) { ods_interesado.Contrasenia = Cifrar(ods_interesado.Contrasenia); db.ods_interesado.Add(ods_interesado); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdMunicipio = new SelectList(db.ods_municipio.OrderBy(t => t.Municipio).ToList(), "IdMunicipio", "Municipio", ods_interesado.IdMunicipio); return(View(ods_interesado)); }
// GET: ods_interesado/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ods_interesado ods_interesado = db.ods_interesado.Find(id); if (ods_interesado == null) { return(HttpNotFound()); } ViewBag.IdMunicipio = new SelectList(db.ods_municipio.OrderBy(t => t.Municipio).ToList(), "IdMunicipio", "Municipio", ods_interesado.IdMunicipio); return(View(ods_interesado)); }
// GET: ods_meta_municipio public ActionResult Index(int?id) { ods_interesado ods_interesado = null; IQueryable <ods_meta_municipio> ods_meta_municipio = null; try { if ((ods_interesado = this.ObtenerInteresado()) == null) { return(RedirectToAction("Autenticar", "Login")); } if (id == null) { ods_meta_municipio = db.ods_meta_municipio.Include(o => o.ods_indicador).Include(o => o.ods_objetivo_municipio); } else { if (id != ods_interesado.IdMunicipio) { id = ods_interesado.IdMunicipio; } ods_meta_municipio = from p in db.ods_meta_municipio where (id == p.IdObjetivoMunicipio) select p; } if (ods_meta_municipio == null) { return(HttpNotFound()); } ViewBag.Interesado = ods_interesado; } catch (Exception /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Debe iniciar sesión principalmente."); } return(View(ods_meta_municipio.ToList())); }
public ActionResult Index(int?id) { ods_interesado ods_interesado = null; IQueryable <ods_indicador> ods_indicador = null; try { if ((ods_interesado = (ods_interesado)Session["ods_interesado"]) == null) { return(RedirectToAction("Autenticar", "Login")); } if (id == null) { ods_indicador = db.ods_indicador; } else { if (id != ods_interesado.IdMunicipio) { id = ods_interesado.IdMunicipio; } ods_indicador = from p in db.ods_indicador where (id == p.IdMunicipio) select p; } if (ods_indicador == null) { return(HttpNotFound()); } ViewBag.Interesado = ods_interesado; } catch (Exception /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Debe iniciar sesión principalmente."); } return(View(ods_indicador.ToList())); }
// GET: ods_objetivo_municipio public ActionResult Index(int?id) { ods_interesado ods_interesado = null; var ods_objetivo_municipio = db.ods_objetivo_municipio.Include(o => o.ods_municipio); try { if ((ods_interesado = this.ObtenerInteresado()) == null) { return(RedirectToAction("Autenticar", "Login")); } ViewBag.Interesado = ods_interesado; } catch (Exception /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Debe iniciar sesión principalmente."); } return(View(ods_objetivo_municipio.ToList())); }
public ActionResult Edit(FormCollection valores) { ods_interesado ods_interesado = null; string vcontrasenia = string.Empty; int IdInteresado = 0; string Interesado = string.Empty; string Nombre = string.Empty; string Usuario = string.Empty; string ContraseniaActual = string.Empty; string Contrasenia = string.Empty; string CorreoRecuperacion = string.Empty; DateTime UltimaSesion = DateTime.Now; string IPUltimaSesion = string.Empty; bool Administrador = false; bool SuperUsuario = false; bool Bloqueado = false; bool Activo = false; int IdMunicipio = 0; try { if (ModelState.IsValid) { var lstContrasenias = ((string)valores["Contrasenia"]).Split(','); Contrasenia = lstContrasenias[0]; ContraseniaActual = lstContrasenias[1]; if (ContraseniaActual == Contrasenia) { vcontrasenia = ContraseniaActual; } else { vcontrasenia = Cifrar(Contrasenia); } string fecha = (string)valores["UltimaSesion"]; IdInteresado = int.Parse(valores["IdInteresado"]); Interesado = (string)valores["Interesado"]; Nombre = (string)valores["Nombre"]; Usuario = (string)valores["Usuario"]; Contrasenia = vcontrasenia; CorreoRecuperacion = (string)valores["CorreoRecuperacion"]; UltimaSesion = DateTime.Parse((string)valores["UltimaSesion"]); IPUltimaSesion = (string)valores["IPUltimaSesion"]; Administrador = bool.Parse(valores["Administrador"].Split(',')[0]); SuperUsuario = bool.Parse(valores["SuperUsuario"].Split(',')[0]); Bloqueado = bool.Parse(valores["Bloqueado"].Split(',')[0]); Activo = bool.Parse(valores["Activo"].Split(',')[0]); IdMunicipio = int.Parse(valores["IdMunicipio"]); ods_interesado = new ods_interesado { IdInteresado = IdInteresado, Interesado = Interesado, Nombre = Nombre, Usuario = Usuario, Contrasenia = vcontrasenia, CorreoRecuperacion = CorreoRecuperacion, UltimaSesion = UltimaSesion, IPUltimaSesion = IPUltimaSesion, Administrador = Administrador, SuperUsuario = SuperUsuario, Bloqueado = Bloqueado, Activo = Activo, IdMunicipio = IdMunicipio }; db.Entry(ods_interesado).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception) { throw; } ViewBag.IdMunicipio = new SelectList(db.ods_municipio.OrderBy(t => t.Municipio).ToList(), "IdMunicipio", "Municipio", ods_interesado.IdMunicipio); return(View(ods_interesado)); }
public ActionResult Index(int?idMunicipio, int?idInteresado) { ods_interesado ods_interesado = null; IQueryable <ods_interesado> lst_ods_interesado = null; try { if ((ods_interesado = (ods_interesado)Session["ods_interesado"]) == null) { return(RedirectToAction("Autenticar", "Login")); } bool autenticado = User.Identity.IsAuthenticated; if (idMunicipio == null && idInteresado == null) { lst_ods_interesado = db.ods_interesado; } else if (idMunicipio != null && idInteresado == null) { if (idMunicipio != ods_interesado.IdMunicipio) { idMunicipio = ods_interesado.IdMunicipio; } lst_ods_interesado = from p in db.ods_interesado where (idMunicipio == p.IdMunicipio && p.SuperUsuario == false) select p; } else if (idMunicipio == null && idInteresado != null) { if (idInteresado != ods_interesado.IdInteresado) { idInteresado = ods_interesado.IdInteresado; } lst_ods_interesado = from p in db.ods_interesado where (idInteresado == p.IdInteresado && p.SuperUsuario == false) select p; } else if (idMunicipio != null && idInteresado != null) { if (idInteresado != ods_interesado.IdInteresado) { idInteresado = ods_interesado.IdInteresado; } lst_ods_interesado = from p in db.ods_interesado where (idMunicipio == p.IdMunicipio && idInteresado == p.IdInteresado && p.SuperUsuario == false) select p; } if (lst_ods_interesado == null) { return(HttpNotFound()); } ViewBag.Interesado = ods_interesado; } catch (Exception /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Debe iniciar sesión principalmente."); } return(View(lst_ods_interesado.ToList())); }