Пример #1
0
        public int CheckLogin(string Username, string Password)
        {
            int Result = 0;

            //Check db
            Password = MD5Hash(Password);
            AccountM A = new AccountM();

            A = AccountM.Login(Username, Password);

            if (!string.IsNullOrEmpty(A.Username))
            {
                Session["AccountID"] = A.AccountID;
                Session["Fullname"]  = A.Fullname;
                Session["Username"]  = A.Username;
                Session["Type"]      = A.Type;
                Result = 1;
            }

            return(Result);
        }
Пример #2
0
        public HttpResponseMessage Login(ReqData req)
        {
            ResData res = new ResData();

            try
            {
                var    Content  = JsonConvert.DeserializeObject <dynamic>(req.Content.ToString());
                string Username = Content.Username.ToString();
                string Password = Content.Password.ToString();

                AccountM AM = AccountM.Login(Username, Password);

                if (AM.AccountID > 0)
                {
                    res.Code       = 1;
                    res.Message    = "Đăng nhập thành công";
                    res.Detail     = AM;
                    res.StatusCode = HttpStatusCode.OK;
                }
                else
                {
                    res.Code       = -1;
                    res.Message    = "Tên đăng nhập hoặc mật khẩu không đúng";
                    res.Detail     = AM;
                    res.StatusCode = HttpStatusCode.NonAuthoritativeInformation;
                }
            }
            catch (Exception ex)
            {
                res.Code       = -99;
                res.Message    = ex.Message;
                res.StatusCode = HttpStatusCode.BadRequest;
            }

            return(Request.CreateResponse(res.StatusCode, res));
        }