本文整理汇总了C#中RegisterModel类的典型用法代码示例。如果您正苦于以下问题:C# RegisterModel类的具体用法?C# RegisterModel怎么用?C# RegisterModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegisterModel类属于命名空间,在下文中一共展示了RegisterModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
};
}
示例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
});
}
示例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;
}
示例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");
}
示例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;
}
示例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>();
}
示例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");
}
示例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");
}
示例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() });
}
示例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);
}