• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RegisterModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RegisterModel的典型用法代码示例。如果您正苦于以下问题:C# RegisterModel类的具体用法?C# RegisterModel怎么用?C# RegisterModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RegisterModel类属于命名空间,在下文中一共展示了RegisterModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Register

        public async Task<IActionResult> Register(RegisterModel model)
        {
            var vm = new RegisterViewModel
            {
                Model = model
            };

            if (!ModelState.IsValid)
            {
                vm.ErrorMessage = Messages.ModelStateNotValid;
                return this.View(vm);
            }

            var result = await this.AccountService.Register(model.UserName, model.Password, model.Email);

            if (result.Success)
            {
                return this.RedirectToAction("RegisterSuccess", "Account");
            }
            else
            {
                switch(result.ErrorCode)
                {
                    case RegisterResult.RegisterErrorCode.EmailExist:
                        vm.ErrorMessage = "该Email已被注册";
                        break;
                    case RegisterResult.RegisterErrorCode.UserNameExist:
                        vm.ErrorMessage = "该用户名已被注册";
                        break;
                }
                
                return this.View(vm);
            }
        }
开发者ID:284247028,项目名称:DotNetClub,代码行数:34,代码来源:AccountController.cs


示例2: Register

        public async Task<ActionResult> Register(RegisterModel model)
        {
            if (!ModelState.IsValid)
            {
                return View();
            }

            var user = new AppUser
            {
                UserName = model.Email,
                Estado = model.Estado,
                Idade = model.Idade
            };

            var result = await _userManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                await SignIn(user);
                return RedirectToAction("Index", "Home");
            }

            foreach (var error in result.Errors)
            {
                ModelState.AddModelError("", error);

            }

            return View();
        }
开发者ID:gustavoferrazfontes,项目名称:DemoIdentity,代码行数:30,代码来源:AuthController.cs


示例3: Register

        public PartialViewResult Register(RegisterModel model)
        {
            if (!string.IsNullOrEmpty(model.Phone) && !Manager.CheckIfPhoneUniq(model.Phone))
                ModelState.AddModelError("Phone", "Taki telefon został już zarejestrowany");

            if (ModelState.IsValid)
            {
                Client newUser = new Client();
                newUser.FirstName = model.Name;
                newUser.Phone = model.Phone;
                newUser.CreationDate = DateTime.Now;
                newUser.Password = model.Password;
                newUser.ActivateCode = Manager.GenerateSmsCode();
                newUser.IsActive = false;
                newUser.SmsSentCount = 1;

                var res = Manager.Add(newUser);

                if (!res.IsError)
                {

                    //TODO wyslac SMS

                    return PartialView("Partial/_registerSuccessPartial", newUser.ClientId);
                }
            }

            return PartialView("Partial/_registerPartial", model);
        }
开发者ID:vitsv,项目名称:GetTaxi,代码行数:29,代码来源:UserController.cs


示例4: Register

        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = _userService.CreateAccount(model.Username, model.Password, model.Email,model.FirstName, model.LastName, model.PhoneNumber, model.Address);
                    if (ModelState.Process(user))
                    {
                        new MembershipEvent(MembershipEventCode.UserCreated, user.Entity).Raise();

                        if (_membershipSettings.RequireAccountVerification)
                        {
                            return View("RegisterSuccess", model);
                        }
                        return View("RegisterConfirm", true);
                    }
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return View(model);
        }
开发者ID:shizik,项目名称:ScaffR-Generated,代码行数:25,代码来源:AccountController.Register.cs


示例5: NewUser

        public ActionResult NewUser(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(
                        model.Email,
                        model.Password,
                        new
                        {
                            Forename = model.Forename,
                            Surname = model.Surname,
                            Email = model.Email
                        });

                    var admin = this._adminService.GetAdminByEmail(model.Email);

                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:james-dibble,项目名称:Embedded-Systems-Assignment,代码行数:30,代码来源:AccountController.cs


示例6: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            this.CreateAccount.TouchUpInside += (object sender, EventArgs e) => {
                //UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null);
                //PreferencesController welcome = (PreferencesController)board.InstantiateViewController ("preferencescontroller");
                //welcome.ImageSources = new string[] { "aaa", "a", "a", "a", "a", "a", "a", "a", "a" };

                //this.NavigationController.PushViewController(welcome, true);
                model = new RegisterModel { Email = this.Email.Text, FirstName = this.FirstName.Text, LastName = this.LastName.Text, Password = this.Password.Text };
                var request = new RestRequest();
                request.Send("http://www.sport.net/api/content/register", "POST", model);
            };

            this.ImagePicker.TouchUpInside += (s, e) => {
                // create a new picker controller
                imagePicker = new UIImagePickerController ();

                // set our source to the photo library
                imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;

                // set what media types
                imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);

                imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                imagePicker.Canceled += Handle_Canceled;

                // show the picker
                NavigationController.PresentViewController (imagePicker, true, null);

            };
        }
开发者ID:jgrozdanov,项目名称:mono-sport,代码行数:33,代码来源:SignUpController.cs


示例7: Index

        public ActionResult Index(RegisterModel model)
        {
            if (ModelState.IsValidField("Email"))
            {
                // check uniqueness on the server
                var index = Global.Client.GetSingleton<LoginsIndexView>();
                if (index.ContainsLogin(model.Email))
                {
                    // could this customer be already registered???
                    // people don't confuse their emails often
                    var result = Global.Auth.PerformLoginAuth(model.Email, model.Password);
                    // OK, this could be customer trying to re-register
                    // let's log him in
                    if (result.IsSuccess)
                    {
                        return Global.Forms.HandleLogin(result.Identity, false);
                    }
                    else
                    {
                        ModelState.AddModelError("Email", string.Format("Email {0} is taken", model.Email));
                    }
                }
            }

            if (!ModelState.IsValid)
                return View("index", model);

            var newGuid = Guid.NewGuid();

            var coll = new NameValueCollection(Request.Headers);

            if (!string.IsNullOrEmpty(Request.UserHostAddress))
            {
                coll.Add("UserHostAddress", Request.UserHostAddress);
            }
            foreach (var language in Request.UserLanguages ?? new string[0])
            {
                coll.Add("UserLanguages", language);
            }

            var reg = new RegistrationInfoBuilder(model.Email, model.CompanyName)
            {
                OptionalUserPassword = model.Password,
                OptionalCompanyPhone = model.ContactPhone,
                Headers = coll,
                OptionalUserName = model.RealName
            };
            Global.Client.SendOne(new CreateRegistration(new RegistrationId(newGuid), reg.Build()));

            return View("wait", new RegisterWaitModel
            {
                RegistrationId = newGuid,
                CompanyName = model.CompanyName,
                ContactPhone = model.ContactPhone,
                Email = model.Email,
                Password = model.Password,
                RealName = model.RealName
            });
        }
开发者ID:syned,项目名称:lokad-cqrs-appharbor,代码行数:59,代码来源:RegisterController.cs


示例8: CreateUser

 /// <summary>
 /// Creates Membership User
 /// </summary>
 /// <param name="Mailadr">E-mail address</param>
 /// <param name="Password">Password string</param>
 /// <param name="PasswordConfirmed">Password confirmed string</param>
 /// <param name="UserID">Outputs user ID</param>
 /// <returns>Boolean (True when user is created, False when sth goes wrong)</returns>
 public bool CreateUser(string Mailadr, string Password, string PasswordConfirmed, out Guid UserID)
 {
     UserID = Guid.Empty;
     RegisterModel NewUser = new RegisterModel { Email = Mailadr, Password = Password, ConfirmPassword = PasswordConfirmed, UserName = Mailadr };
     MembershipCreateStatus createStatus;
     Membership.CreateUser(NewUser.UserName, NewUser.Password, NewUser.Email, null, null, true, null, out createStatus);
     if (createStatus == MembershipCreateStatus.Success)
     {
         UserID = (Guid)Membership.GetUser(Mailadr).ProviderUserKey;
         return true;
     }
     return false;
 }
开发者ID:jager,项目名称:Referee,代码行数:21,代码来源:UserDomain.cs


示例9: Index_ValidateSuccess

        public void Index_ValidateSuccess()
        {
            //Arrange
            var registerModel = new RegisterModel
            {
                Email = "[email protected]",
                Password = "password"
            };

            //Assign
            var result = _controller.Register(registerModel) as RedirectToRouteResult;

            //Assert
            result.RouteValues["Action"].ShouldBeEqual("Index");
        }
开发者ID:chisinus,项目名称:FormBuddy,代码行数:15,代码来源:UT_HomeControllerTest.cs


示例10: ConvertRegistrationModelToUser

        public static User ConvertRegistrationModelToUser(RegisterModel model)
        {
            User u = new User
            {
                UserName = model.UserName,
                Firstname = model.Firstname,
                Lastname = model.Lastname,
                Password = model.Password,
                EmailAddress = model.Email,
                GeekUserName = model.GeekUserName,
                FacebookDetails = new FacebookUser { email = model.Email },
            };

            return u;
        }
开发者ID:BigBearGCU,项目名称:LanarkshireGamers,代码行数:15,代码来源:BusinessLogicHelper.cs


示例11: RegisterCommand

 public FubuContinuation RegisterCommand(RegisterModel input)
 {
     // TODO: VALIDATION
     if (input.UserName.IsEmpty() || input.Password.IsEmpty()) {
         return FubuContinuation.TransferTo<RegisterInput>();
     }
     if (!input.Password.Equals(input.ConfirmPassword)) {
         return FubuContinuation.TransferTo<RegisterInput>();
     }
     if (_membershipService.CreateUser(input.UserName, input.Password, input.Email)) {
         _authenticationContext.ThisUserHasBeenAuthenticated(input.UserName, false);
         return FubuContinuation.RedirectTo<IndexInput>();
     }
     return FubuContinuation.TransferTo<RegisterInput>();
 }
开发者ID:emiaj,项目名称:FubuMvcSparkProjectTemplate,代码行数:15,代码来源:RegisterEndpoint.cs


示例12: Register

        public async Task<ActionResult> Register(RegisterModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var user = await _applicationService.GetCandidateByEmailAsync(model.Email);
            if (user != null)
            {
                ModelState.AddModelError("Email", "User with this email already exists.");
                return View(model);
            }
            await _applicationService.CreateCandidateUserAsync(model);
            return RedirectToAction("Index", "Home");
        }
开发者ID:ibezuglyi,项目名称:Summer2015,代码行数:16,代码来源:CandidateController.cs


示例13: Register

        public async Task<ActionResult> Register(RegisterModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var blogContext = new BlogContext();
            var user = new User
            {
                Name = model.Name,
                Email = model.Email
            };

            await blogContext.Users.InsertOneAsync(user);
            return RedirectToAction("Index", "Home");
        }
开发者ID:ibezuglyi,项目名称:mongo.blog,代码行数:17,代码来源:AccountController.cs


示例14: JsonRegister

        public ActionResult JsonRegister(RegisterModel model)
        {
            if (ModelState.IsValid) {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, passwordQuestion: null, passwordAnswer: null, isApproved: true, providerUserKey: null, status: out createStatus);

                if (createStatus == MembershipCreateStatus.Success) {
                    FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: false);
                    return Json(new { success = true });
                } else {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed
            return Json(new { errors = GetErrorsFromModelState() });
        }
开发者ID:hpinsley,项目名称:SportsRank,代码行数:18,代码来源:AccountController.cs


示例15: Register

        public virtual ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                Status status;
                if(model.Register(out status))
                    return this.RedirectToAction<HomeController>(a => a.Index());
                
                ModelState.AddModelError("Error", status.Message());
            }
            else
            {
                ModelState.AddModelError("Error", "Please update the required fields");
            }

            // Initialize the meta data information
            model = BaseModelHelper.GetRegisterModel(model);
            return View(model);
        }
开发者ID:kscott5,项目名称:HolyAngels,代码行数:19,代码来源:UserController.cs


示例16: TestRegisterPost_ValidUser_ReturnsRedirect

        public void TestRegisterPost_ValidUser_ReturnsRedirect()
        {
            // Arrange
            AccountController controller = new AccountController(_shoppingCartFactory, _securityProvider, _session);
            var model = new RegisterModel()
            {
                UserName = "someUser",
                Password = "goodPassword",
                ConfirmPassword = "goodPassword"
            };

            // Act
            ActionResult result = controller.Register(model);

            // Assert
            var redirectResult = (RedirectToRouteResult)result;
            Assert.AreEqual("Home", redirectResult.RouteValues["controller"]);
            Assert.AreEqual("Index", redirectResult.RouteValues["action"]);
        }
开发者ID:AndrewLeanSSW,项目名称:SSW.Training.MusicStore.Enterprise,代码行数:19,代码来源:HomeControllerTest.cs


示例17: User

        public User(RegisterModel registermodel)
        {
            UserName = registermodel.UserName;
            Password = registermodel.Password;
            FirstName = registermodel.FirstName;
            LastName = registermodel.LastName;
            Address = registermodel.Address;
            ContactNumber = registermodel.MobileNumber;
            DateOfBirth = registermodel.DateOfBirth;
            EmailId = registermodel.EmailID;
            SecurityQuestion = registermodel.SecurityQuestion;
            Answer = registermodel.SecurityAnswer;
            AddressProof = Image.FromStream(registermodel.AddressProof.InputStream, true, true);
            //PhotoIdentity = registermodel.PhotoIdentity;
            PhotoIdentity = Image.FromStream(registermodel.PhotoIdentityProof.InputStream, true, true);

            Status = 0;
            RewardPoints = 0;
        }
开发者ID:sunnyrajrathod,项目名称:OnePointTelecom,代码行数:19,代码来源:User.cs


示例18: Create

 public Member Create(RegisterModel model)
 {
     Member mb = new Member();
     mb.Email = model.Email;
     mb.NickName = model.NickName;
     mb.OpenID = model.OpenID;
     mb.OpenType = model.OpenType;
     mb.Status = (int)MemberStatus.Registered;//注册未激活,0为禁用
     mb.Password = CheckHelper.StrToMd5(model.Password);
     mb.GroupID = 1;
     mb.AddTime = DateTime.Now;
     mb.LastTime = DateTime.Now;
     mb.AddIP = HttpHelper.IP;
     mb.LastIP = HttpHelper.IP;
     mb.LoginCount = 1;
     DB_Service.Add<Member>(mb);
     DB_Service.Commit();
     return mb;
 }
开发者ID:navy235,项目名称:adzhi,代码行数:19,代码来源:MemberService.cs


示例19: Register

        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:20,代码来源:AccountController.cs


示例20: Register

        public ActionResult Register(RegisterModel model)
        {
            string hash;
            string salt;
            new SaltedHash().GetHashAndSaltString(model.Password, out hash, out salt);

            var user = new UserAuth
                {
                    DisplayName = model.UserName,
                    Email = model.Email,
                    UserName = model.UserName,
                    PasswordHash = hash,
                    Salt = salt
                };

            var response = UserAuthRepo.CreateUserAuth(user, model.Password);
            var authResponse = AuthService.Authenticate(new Auth {UserName = model.UserName, Password = model.Password, RememberMe = true});

            return RedirectToAction("Index", "Home");
        }
开发者ID:senseicz,项目名称:UniPhotogallery,代码行数:20,代码来源:AccountController.cs



注:本文中的RegisterModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RegisterStorage类代码示例发布时间:2022-05-24
下一篇:
C# Register类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap