public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { // var user = new ApplicationUser { UserName = model.FirstName + " " + model.LastName, Email = model.Email}; var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); await this.UserManager.AddToRoleAsync(user.Id, model.Role); /*StreamReader sr = new StreamReader(Server.MapPath("~/Content/states_hash.json")); * string data = sr.ReadToEnd(); * JArray arr = JArray.Parse(data); * for (int i = 0; i < arr.Count(); i++) * { * model.stateList.Add(new SelectListItem { Text = (string)arr[i]["name"], Value = (string)arr[i]["name"] }); * }*/ User HarmonyUser = new User { FirstName = model.FirstName, LastName = model.LastName, Email = user.Email, City = model.City, State = model.State, Description = model.Description, ASPNetIdentityID = user.Id }; db.Users.Add(HarmonyUser); if (model.Role == "VenueOwner") { VenueType venueType = new VenueType { TypeName = model.VenueType }; Venue venue = new Venue { VenueName = model.VenueName, AddressLine1 = model.AddressLine1, AddressLine2 = model.AddressLine2, City = model.VenueCity, State = model.VenueState, ZipCode = model.ZipCode, UserID = HarmonyUser.ID, VenueTypeID = venueType.ID }; db.VenueTypes.Add(venueType); db.Venues.Add(venue); } if (model.Role == "Musician") { List <Genre> genres = new List <Genre>(); List <string> genreList = new List <string>(); List <string> instrumentList = new List <string>(); List <string> bandmemberList = new List <string>(); genreList = model.GenreName.Split(',').ToList(); for (int i = 0; i < genreList.Count(); i++) { genres.Add(new Genre { GenreName = genreList[i] }); db.Genres.Add(genres[i]); HarmonyUser.Genres.Add(genres[i]); } } await db.SaveChangesAsync(); return(RedirectToAction("Welcome", "Home")); } AddErrors(result); } // ViewBag.State = stateList; // ViewData["State"] = stateList; // If we got this far, something failed, redisplay form return(View(model)); }