Ejemplo n.º 1
0
        private void Login()
        {
            UserValidationModel model = new UserValidationModel();

            model.LoginName = textBoxName.Text.TrimStart().TrimEnd();
            model.Password  = textBoxPassWord.Text;
            if (String.IsNullOrEmpty(model.LoginName) || String.IsNullOrEmpty(model.Password))
            {
                labelMessage.Text = "请录入登录信息";
            }
            else
            {
                HandlingResult   result = new HandlingResult();
                ValidationAction action = new ValidationAction();
                result = action.ValidateLogin(model);
                if (result.Successed)
                {
                    UserInformationModel user = (UserInformationModel)result.Result;
                    UserInformationContext.ID        = user.Id;
                    UserInformationContext.Name      = user.Name;
                    UserInformationContext.LoginName = user.LoginName;
                    UserInformationContext.LoginTime = DateTime.Now;
                    UserInformationContext.LoginPass = true;
                    UserInformationContext.StoreId   = "";
                    Close();
                }
                else
                {
                    labelMessage.Text = result.Message;
                }
            }
        }
Ejemplo n.º 2
0
        public UserViewModel GetDetails(UserValidationModel validationModel)
        {
            var user = _unitOfWork.userRepository.All.FirstOrDefault(
                entity => entity.UserName == validationModel.UserName && entity.Password == validationModel.Password);

            return(new UserViewModel(user));
        }
Ejemplo n.º 3
0
        public HandlingResult ValidateLogin(UserValidationModel model)
        {
            HandlingResult result = new HandlingResult();

            result.Successed = false;
            DataTable dt  = null;
            String    sql = String.Format("SELECT * FROM BPSYS_USER WHERE LOGINNAME='{0}'", model.LoginName);

            using (DataBaseProcess process = new DataBaseProcess())
            {
                dt = process.Query(sql);
            }
            if (dt != null && dt.Rows.Count > 0)
            {
                UserInformationModel usermodel = new UserInformationModel()
                {
                    Id        = Guid.Parse(dt.Rows[0]["ID"].ToString()),
                    LoginName = dt.Rows[0]["LOGINNAME"].ToString(),
                    Name      = dt.Rows[0]["NAME"].ToString(),
                    StoreId   = dt.Rows[0]["STOREID"].ToString(),
                };
                String pw = Md5Helper.GetMD5String(model.Password);
                if (pw.Equals(dt.Rows[0]["PASSWORD"].ToString()))
                {
                    result.Result    = usermodel;
                    result.Successed = true;
                }
                else
                {
                    result.Message = "用户名或密码错误!";
                }
            }
            else
            {
                result.Message = "用户名或密码错误";
            }
            return(result);
        }
        public ActionResult Validate([FromBody] UserValidationModel loginAttempt)
        {
            var results = _userService.Validate(loginAttempt);

            return(Ok(results));
        }
        public ActionResult Details(UserValidationModel validationModel)
        {
            var results = _userService.GetDetails(validationModel);

            return(Ok(results));
        }