Exemple #1
0
 public ActionResult Index(LoginViewModel login, string Command)
 {
     //secion de comando iniciar sesión
     if (Command == "Iniciar Sesión")
     {
         if (ModelState.IsValid)
         {
             AppSession app = new AppSession();
             if (app.Login(login.UserName, login.Password))
             {
                 if (app.UserType == "Prepago")
                 {
                     Session["titulo"] = "Administrador PREPAGO";
                 }
                 else
                 {
                     Session["titulo"] = "Administrador SUMA";
                 }
                 //para guardar el RoleLevel
                 Session["RoleLevel"] = app.RoleLevel;
                 Session["login"] = app.UserLogin;
                 Session["username"] = app.UserName;
                 Session["userid"] = app.UserID;
                 Session["type"] = app.UserType;
                 Session["menu"] = app.MenuList;
                 Session["appdate"] = app.AppDate;
                 ViewBag.AppDate = app.AppDate;
                 ViewBag.Menu = app.MenuList;
                 return View();
             }
             else
             {
                 ModelState.Clear();
                 ModelState.AddModelError("UserName", "La combinación Usuario/Contraseña es inválida.");
                 return View("Login", login);
             }
         }
         else
         {
             return View("Login", login);
         }
     }
     //secion de comando olvidó contraseña
     else
     {
         if (login.UserName == null)
         {
             ModelState.Clear();
             ModelState.AddModelError("UserName", "El campo Usuario es obligatorio.");
             return View("Login", login);
         }
         using (LealtadEntities db = new LealtadEntities())
         {
             db.Database.Connection.ConnectionString = AppModule.ConnectionString("SumaLealtad");
             User user = (from u in db.Users
                          where u.login.Equals(login.UserName)
                          select u).FirstOrDefault();
             if (user == null)
             {
                 ModelState.Clear();
                 ModelState.AddModelError("UserName", "El Usuario suministrado no existe. Verifique.");
                 return View("Login", login);
             }
         }
         CambiarPasswordViewModel cambiarpassword = new CambiarPasswordViewModel()
         {
             UserName = login.UserName
         };
         return View("CambiarPassword", cambiarpassword);
     }
 }
Exemple #2
0
 public ActionResult Login()
 {
     Session["titulo"] = "Administrador SUMA / PREPAGO";
     Session["login"] = null;
     //PARA GUARDAR EL AMBIENTE DE CORRIDA CONFIGURADO EN EL WEBCONFIG
     Session["ambiente"] = ConfigurationManager.AppSettings["AMBIENTE"].ToString();
     //PARA GUARDAR LA VERSION CONFIGURADO EN EL WEBCONFIG
     Session["version"] = ConfigurationManager.AppSettings["VERSION"].ToString();
     LoginViewModel login = new LoginViewModel();
     return View(login);
 }