public ActionResult SendInvite(FormCollection collection) { //TODO: check credentials - throw error var email = collection.Get("email"); var registrationRepo = new RegistrationDetailRepository(); //TODO: check if invite wasn't already sent var regCode = registrationRepo.CreateEntry(email); var body = String.Format("{0} {1}{2}", EmailServerRepository.DefaultBody, EmailServerRepository.DefaultRegistrationLink, regCode); UtilMethods.SendEmail(email, EmailServerRepository.DefaultSubject, body); //TODO show success message return(View()); }
// // GET: /User/Create/eadd2f20cf91498d901085254868e687 public ActionResult Create(string id) { if (String.IsNullOrWhiteSpace(id)) { return(Content("Invalid registration code !")); } var repo = new RegistrationDetailRepository(); if (!repo.ValidateRegistrationCode(id)) { return(Content("Invalid registration code !")); } var regDetail = repo.GetEntry(id); var model = new UserRegistrationModel { Email = regDetail.Email }; return(View(model)); }
public ActionResult Create(string id, UserRegistrationModel model) { try { var repo = new RegistrationDetailRepository(); var regDetail = repo.GetEntry(id); // check same email wasn't used before if (userRepo.CheckUserExists(regDetail.Email)) { return(Content("E-mail address already used for user registration !")); } if (model.Password != model.ConfirmationPassword) { ModelState.AddModelError(String.Empty, "Non-matching passwords !"); return(View(model)); } // create user var user = new User { Email = regDetail.Email, Firstname = model.Firstname, Lastname = model.Lastname, Password = model.Password }; userRepo.CreateUser(ref user, id); return(RedirectToAction("Index", "Login")); } catch { return(View()); } }