Example #1
0
        public ActionResult _CreateUser(ManageUsersCreateEditModel model)
        {
            User             user   = model.AsUser();
            UserCreateStatus status = UserCreateStatus.UnknownFailure;

            user.IsActivated = true;

            IUser       createdUser = iMembershipService.CreateUser(user, model.Password, out status);
            UserProfile profile     = UserProfile.New();

            profile.UserId = createdUser.UserId;
            new UserProfileService().Create(profile);
            StatusMessageData statusMessageData = null;

            switch (status)
            {
            case UserCreateStatus.DisallowedUsername:
                WebUtility.SetStatusCodeForError(Response);
                statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,您输入的帐号禁止使用,请输入其他名称");
                break;

            case UserCreateStatus.DuplicateEmailAddress:
                WebUtility.SetStatusCodeForError(Response);
                statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,您输入的电子邮箱地址已经被使用,请输入其他邮箱");
                break;

            case UserCreateStatus.DuplicateUsername:
                WebUtility.SetStatusCodeForError(Response);
                statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,您输入的帐号已经被使用,请输入其他名称");
                break;

            case UserCreateStatus.InvalidPassword:
                WebUtility.SetStatusCodeForError(Response);
                statusMessageData = new StatusMessageData(StatusMessageType.Error, "您的密码长度少于本站要求的最小密码长度,请重新输入");
                break;

            case UserCreateStatus.UnknownFailure:
                WebUtility.SetStatusCodeForError(Response);
                statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,注册新用户的时候产生了一个未知错误");
                break;

            default:
                break;
            }
            ViewData["statusMessageData"] = statusMessageData;
            if (statusMessageData == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Success, "创建成功!")));
            }
            else
            {
                return(View(model));
            }
        }
        public ActionResult _CreateUser(ManageUsersCreateEditModel model)
        {
            User user = model.AsUser();
            UserCreateStatus status = UserCreateStatus.UnknownFailure;
            user.IsActivated = true;

            IUser createdUser = iMembershipService.CreateUser(user, model.Password, out status);
            UserProfile profile = UserProfile.New();
            profile.UserId = createdUser.UserId;
            new UserProfileService().Create(profile);
            StatusMessageData statusMessageData = null;
            switch (status)
            {
                case UserCreateStatus.DisallowedUsername:
                    WebUtility.SetStatusCodeForError(Response);
                    statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,您输入的帐号禁止使用,请输入其他名称");
                    break;
                case UserCreateStatus.DuplicateEmailAddress:
                    WebUtility.SetStatusCodeForError(Response);
                    statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,您输入的电子邮箱地址已经被使用,请输入其他邮箱");
                    break;
                case UserCreateStatus.DuplicateUsername:
                    WebUtility.SetStatusCodeForError(Response);
                    statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,您输入的帐号已经被使用,请输入其他名称");
                    break;
                case UserCreateStatus.InvalidPassword:
                    WebUtility.SetStatusCodeForError(Response);
                    statusMessageData = new StatusMessageData(StatusMessageType.Error, "您的密码长度少于本站要求的最小密码长度,请重新输入");
                    break;
                case UserCreateStatus.UnknownFailure:
                    WebUtility.SetStatusCodeForError(Response);
                    statusMessageData = new StatusMessageData(StatusMessageType.Error, "对不起,注册新用户的时候产生了一个未知错误");
                    break;
                default:
                    break;
            }
            ViewData["statusMessageData"] = statusMessageData;
            if (statusMessageData == null)
            {
                return Json(new StatusMessageData(StatusMessageType.Success, "创建成功!"));
            }
            else
            {
                return View(model);
            }
        }
Example #3
0
        public ActionResult _CreateUser()
        {
            ManageUsersCreateEditModel model = new ManageUsersCreateEditModel();

            return(View(model));
        }
 public ActionResult _CreateUser()
 {
     ManageUsersCreateEditModel model = new ManageUsersCreateEditModel();
     return View(model);
 }