public ActionResult AttorneySignUp() { if (Session["AcceptedUseAgreement"] != null && ((bool)Session["AcceptedUseAgreement"]) == true) { ViewData["PasswordLength"] = MembershipService.MinPasswordLength; var model = new AttorneySignUpModel { Counties = new SelectList(_repository.Counties.ToList(), "Id", "CountyName") }; return View(model); } return RedirectToAction("UseAgreement"); }
public ActionResult AttorneySignUp(AttorneySignUpModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus createStatus = MembershipService.CreateAttorney(model.UserName, model.Password, model.Email); if (createStatus == MembershipCreateStatus.Success) { var profile = UserProfile.GetUserProfile(model.UserName); profile.FirstName = model.FirstName; profile.MiddleInitial = model.MiddleInitial; profile.LastName = model.LastName; profile.AddressLine1 = model.AddressLine1; profile.AddressLine2 = model.AddressLine2; profile.City = model.City; profile.County = _repository.Counties.First(x => x.Id == model.County).CountyName; profile.DisciplinaryBoardNumber = model.DisciplinaryBoardNumber; profile.LawFirm = model.Organization; profile.Phone = model.Phone; profile.State = model.State; profile.Zip = model.Zip; profile.RegistrationDate = DateTime.Now; profile.Save(); Roles.AddUserToRole(model.UserName, UserRoles.PendingApproval); FormsService.SignIn(model.UserName, false /* createPersistentCookie */); _emailService.SendEmailTo(model.Email, new LawyerRegistrationEmail(model.UserName, model.Password)); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus)); } } // If we got this far, something failed, redisplay form ViewData["PasswordLength"] = MembershipService.MinPasswordLength; model.Counties = new SelectList(_repository.Counties.ToList(), "Id", "CountyName"); return View(model); }