How can I use the MembershipCreateStatus in my controller below to identify errors?
My controller below creates a new user but I would like to catch any errors from CreateStatus and add the error to my modelstate.
I keep getting errors for status below.
[HttpPost]
public ActionResult CreateUser(user UserToCreate)
{
if (ModelState.IsValid)
{
// TODO: If the UserToCreate object is Valid we'll
//Eventually want to save it in a database
MembershipCreateStatus status;
MembershipService newMembershipService = new MembershipService();
MembershipCreateStatus newUser = newMembershipService.CreateUser(UserToCreate.Username, UserToCreate.Password, UserToCreate.Email,out MembershipCreateStatus **status**);
if (newUser == MembershipCreateStatus.Success)
{
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError(createStatus);
return Redirect("/");
}
}
//Invalid - redisplay form with errors
return View(UserToCreate);
}