public async Task <ActionResult> RegisterUser(App.Models.UserViewModel model, string Argument) { var user = this.UserViewModelUserMap(model); user.Company = (Company)Session["company"]; UserManager.UserValidator = new UserValidator <ApplicationUser>(UserManager) { AllowOnlyAlphanumericUserNames = false }; var result = await UserManager.CreateAsync(user, model.Password); modelContext.SaveChanges(); if (result.Succeeded) { await enviarMailConfirmacion(user); this.enviarMailHabilitacionToAdmin(user); } else { AddErrors(result); } modelContext.SaveChanges(); return(RedirectToAction("WaitConfirmation", "../Product/Evaluation")); }
private ApplicationUser UserViewModelUserMap(App.Models.UserViewModel model) { var user = new ApplicationUser() { UserName = model.UserName, FirstName = model.FirstName, LastName = model.LastName, Email = Session["email"].ToString(), Enabled = false }; user.Roles.Add(new IdentityUserRole { RoleId = "2", UserId = user.Id }); return(user); }