예제 #1
0
 public ActionResult Index(LoginModel lg)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var res = ad.checkLogin(lg.Username, lg.Password);
             if (res == true)
             {
                 var user        = ad.GetByID(lg.Username);
                 var userSession = new UserLogin();
                 userSession.Username = user.Username;
                 userSession.ID       = user.ID;
                 userSession.FullName = user.FullName;
                 userSession.Point    = user.AccountPoint;
                 Session.Add(CommonConstants.USER_SESSION, userSession);
                 return(RedirectToAction("/", "Home"));
             }
             else
             {
                 ModelState.AddModelError("", "Login failed!");
             }
         }
         return(View(lg));
     }
     catch
     {
         return(View());
     }
 }
예제 #2
0
        public ActionResult Index(ManagerLoginModel lg)
        {
            var res = mlg.checkAdminLogin(lg.Username, lg.Password);

            if (res)
            {
                AccountData ad          = new AccountData();
                var         user        = ad.GetByID(lg.Username);
                var         userSession = new UserLogin();
                userSession.Username = user.Username;
                userSession.ID       = user.ID;
                userSession.FullName = user.FullName;
                Session.Add(CommonConstants.USER_SESSION, userSession);
                return(RedirectToAction("Index", "Dashboash"));
            }
            else
            {
                ModelState.AddModelError("", "Login failed!");
            }
            return(View());
        }