Ejemplo n.º 1
0
        public ActionResult login(login l)
        {
            login lg = new login();

            if (ModelState.IsValid)
            {
                using (FACCTEntities lge = new FACCTEntities())
                {
                    var v = lge.useraccounts.Where(a => a.Name.Equals(l.UserName) && a.Password.Equals(l.Password)).FirstOrDefault();
                    if (v != null)
                    {
                        Session["LogedUserID"]       = v.UserName.ToString();
                        Session["LogedUserFullname"] = v.Password.ToString();
                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(View("login"));
        }
Ejemplo n.º 2
0
        public ActionResult Index(string username, string password)
        {
            using (FACCTEntities lge = new FACCTEntities())
            {
                //var v=lge.useraccounts.Where(m=>m.UserName.Trim()==username.Trim() && m.Password==password).ToList();
                //var v = lge.useraccounts.Where(a => string.Equals(a.Name,username) && string.Equals(a.Password,password)).FirstOrDefault();
                //if (v !=null)
                {
                    Session["role"]        = "admin";
                    Session["username"]    = username;
                    Session["pass"]        = password;
                    Session["isUservalid"] = true;
                    Session["loginExpiry"] = DateTime.Now.AddMinutes(2);
                    if (authenticateuser())
                    {
                        return(RedirectToAction("Index", "Home", new { }));
                    }
                }
                ViewData["Message"] = "u";
                return(View("Index"));

                // return View("Alert");
            }
        }