public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { // this collects information for AspNetUsers var user = new ApplicationUser() { UserName = model.UserName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // This will collect information for the AccountCredentials Account newAccount = new Account() { Username = model.UserName, Email = model.Email }; db.AddAccount(newAccount); await SignInAsync(user, isPersistent: false); return RedirectToAction("Index", "Home"); } else { AddErrors(result); } } // If we got this far, something failed, redisplay form ViewBag.Login = new LoginViewModel(); ViewBag.Register = model; return View(model); }
public void AddAccount(Account acc) { db.Accounts.Add(acc); db.SaveChanges(); }