public ActionResult CreaUtente(CreaUtenteModel model) { ActionResult result = null; Utente nuovoUtente = null; string nomeUtente = ""; string token = ""; string urlCreazioneToken = ""; //string oggettoMail = ""; //StringBuilder bodyMail = new StringBuilder(); if (ModelState.IsValid) { MembershipService service = new MembershipService(); nomeUtente = service.GeneraNomeUtente(model.Nome, model.Cognome); using (TransactionScope tScope = new TransactionScope()) { try { nuovoUtente = service.CreaNuovoUtenteESalva(nomeUtente, model.Nome, model.Cognome, true, model.Email); // result = RedirectToAction("GestioneRuoli", new { id = nuovoUtente.ID }); token = MembershipService.GeneraTokenPrimoLogin(nuovoUtente); urlCreazioneToken = Url.Action("ResetPassword", "Home", new { t = token }, this.Request.Url.Scheme); EmailService.InvioToken(urlCreazioneToken, nuovoUtente, TipoEmail.Registrazione); model.UtenteRegistrato = true; result = View(model); tScope.Complete(); } catch (Exception ex) { ModelState.AddModelError("", "Si รจ verificato un errore nella creazione dell'utente"); new VAWebRequestErrorEvent("Errore in creazione utente", this, ex).Raise(); result = View(model); } finally { tScope.Dispose(); } } } else { result = View(model); } return(result); }
public ActionResult CreaUtente() { CreaUtenteModel model = new CreaUtenteModel(); return(View(model)); }