Esempio n. 1
0
        public ActionResult CheckLogin(LoginExecuteSearchAction CommandAction)
        {
            try
            {
                var result = CommandAction.Execute();
                if (result.Count() == 1)
                {
                    this.Session["Email"]        = CommandAction.Username;
                    this.Session["EmployeeName"] = result[0].EmployeeName;
                    this.Session["LastLogin"]    = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    this.Session["Photo"]        = "/img/demo/avatar/avatar1.jpg";

                    this.Session.Timeout = 10;
                    using (var cmd = new LoginUpdateRepository())
                    {
                        result[0].LastLogin = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                        result[0].Token     = this.Session.SessionID;
                        cmd.Item            = result[0];
                        var res = cmd.Execute();
                        return(JsonExpando(Success(res)));
                    }
                }
                return(JsonExpando(Success(false, "Tên tài khoản hoặc mật khẩu không đúng!")));
            }
            catch (Exception ex)
            {
                return(JsonExpando(Success(false, ex.Message)));
            }
        }
Esempio n. 2
0
 public ActionResult CheckLogin(LoginExecuteSearchAction CommandAction)
 {
     try
     {
         var result = CommandAction.Execute();
         if (result.Count() == 1)
         {
             this.Session["Username"]  = CommandAction.Username;
             this.Session["LastLogin"] = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
             using (var cmd = new LoginUpdateRepository())
             {
                 result[0].LastLogin = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                 cmd.Item            = result[0];
                 var res = cmd.Execute();
                 return(Json(Result.Success(res)));
             }
         }
         return(Json(Result.Success(false, "Tên tài khoản hoặc mật khẩu không đúng!")));
     }
     catch (Exception ex)
     {
         return(Json(Result.Success(false, ex.Message)));
     }
 }