public ActionResult XuLyLogin(Login model)
 {
     if (ModelState.IsValid)
     {
         var dao    = new DataAccessObject();
         var result = dao.Login(model.UserName, FileMaHoa.MD5Hash(model.Password));
         if (result == 1)
         {
             var user        = dao.GetByID(model.UserName);
             var userSession = new UserLogin();
             userSession.UserName = user.UserName;
             userSession.UserID   = user.ID;
             userSession.GroupID  = user.GroupID;
             var listPermission = dao.GetListPermission(model.UserName);
             Session.Add(CommonConstants.SESSION_PERMISSION, listPermission);
             Session.Add(CommonConstants.USER_SESSION, userSession);
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             if (result == -1)
             {
                 ModelState.AddModelError("", "Tài Khoản Không Tồn Tại!!!");
             }
             if (result == -2)
             {
                 ModelState.AddModelError("", "Mật Khẩu Không Đúng!!!");
             }
         }
     }
     return(View("DangNhap"));
 }
        public ActionResult IndexLogin()
        {
            var dao = new DataAccessObject();
            var tmp = Session[CommonConstants.USER_SESSION] as UserLogin;

            return(View(dao.GetByID(tmp.UserName)));
        }
Exemplo n.º 3
0
        public object GetByID(object keyValues, GetByIDParameters parameters = null)
        {
            Check.Require(_IsInitialized, "The class is not initialized yet.");
            if (parameters == null)
            {
                parameters = new GetByIDParameters();
            }

            object typedKeyObject = GetKeyObject(keyValues);

            if (onBeforeGetByID(typedKeyObject, parameters))
            {
                object entityObj = DataAccessObject.GetByID(typedKeyObject, parameters);

                foreach (EntitySecurityBase checker in this.SecurityCheckers)
                {
                    checker.GetByID(keyValues, parameters, entityObj);
                }

                onAfterGetByID(entityObj, typedKeyObject, parameters);
                return(entityObj);
            }
            return(null);
        }