예제 #1
0
        private dynamic DoRegist()
        {
            bool success = false;

            if (string.IsNullOrWhiteSpace(Request.Form.username) || string.IsNullOrWhiteSpace(Request.Form.password))
            {
                ViewBag.Error = "用户名或密码不能为空!";
            }
            else
            {
                var user = _userDb.Get(Request.Form.username as string);
                if (user == null)
                {
                    _userDb.Add(new User()
                    {
                        username = Request.Form.username,
                        password = Request.Form.password,
                        email    = Request.Form.email,
                        nicename = Request.Form.nicename
                    });
                    success = true;
                }
                else
                {
                    ViewBag.Error = "改用户名已经存在!";
                }
            }

            if (success)
            {
                return(new RedirectResponse("/login"));
            }
            else
            {
                return(View["user/regist"]);
            }
        }