Ejemplo n.º 1
0
        // GET: Admin
        public ActionResult Index(Admin admin)
        {
            string u = admin.userName;
            string p = admin.password;

            if (ModelState.IsValid)
            {
                AirWarCollege db  = new AirWarCollege();
                var           log = db.Admins.Where(a => a.userName.Equals(u) && a.password.Equals(p)).FirstOrDefault();
                if (log != null)
                {
                    Session["userName"] = log.userName;
                    return(RedirectToAction("Index", "AdminActions"));
                }
                else if (admin.password.Length <= 6)
                {
                    Response.Write("<script>alert('Invalid username or password')</script>");
                }
                else
                {
                    Response.Write("<script>alert('Invalid username or password')</script>");
                }
            }
            return(View());
        }