コード例 #1
0
        public ActionResult Register(RegisterModel model)
        {
            var re = string.Empty;

            if (ModelState.IsValid)
            {
                if (!MyService.UserExist(model.UserName.Trim()))
                {
                    var user = new UserInfoModel
                    {
                        UserName = model.UserName.Trim(),
                        UserPwd  = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "md5"),
                        RoleId   = GetRoleId(model.UserName)
                    };
                    MyService.AddUser(user);
                    Session.Add("user", MyService.UserExist(user.UserName, user.UserPwd));
                }
                else
                {
                    re = res.Register_UsernameExists;
                }
            }
            else
            {
                re = res.SysError;
            }
            return(Content(re, "text/html;charset=UTF-8"));
        }