Created
January 12, 2012 13:03
-
-
Save pauldambra/1600391 to your computer and use it in GitHub Desktop.
Edited Register Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public ActionResult Register(RegisterModel model) | |
{ | |
if (ModelState.IsValid) | |
{ | |
// Attempt to register the user | |
MembershipCreateStatus createStatus; | |
Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); | |
if (createStatus == MembershipCreateStatus.Success) | |
{ | |
FormsAuthentication.SetAuthCookie(model.UserName, false); | |
//Changes here | |
//Create loads or creates a profile based on searching for username | |
var userProfile = ProfileBase.Create(model.UserName) as CustomProfile; | |
userProfile.Address = model.Address; | |
userProfile.Save(); | |
//End of changes | |
return RedirectToAction("Index", "Home"); | |
} | |
else | |
{ | |
ModelState.AddModelError("", ErrorCodeToString(createStatus)); | |
} | |
} | |
// If we got this far, something failed, redisplay form | |
return View(model); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment