Exemplo n.º 1
0
        public ResultDTO Login(LoginDTO model)
        {
            ResultDTO result = new ResultDTO();

            try
            {
                if (string.IsNullOrWhiteSpace(model.UserName))
                {
                    result.Code    = 0;
                    result.Message = "please input username";
                }
                Users user = login.GetUsers(model.UserName);

                if (user != null)
                {
                    string MD5Pwd = MD5ER.MD5Encryp(model.Password);
                    if (MD5Pwd != user.Password)
                    {
                        result.Message = "密码错误";
                    }
                    else
                    {
                        result.Code    = 1;
                        result.Message = "正在登陆。。。";
                    }
                }
            }
            catch (Exception ex)
            {
                result.Code    = 0;
                result.Message = "系统错误";
            }
            return(result);
        }
        public ResultDTO AddUser(string UserName, string Password)
        {
            ResultDTO result = new ResultDTO();

            Users user = new Users()
            {
                UserId      = System.Guid.NewGuid().ToString("N"),
                AccountName = UserName,
                Password    = MD5ER.MD5Encryp(Password),
                Status      = 1
            };

            register.AddUser(user);

            result.Code    = 0;
            result.Message = "注册成功";

            return(result);
        }