public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid == false) return View(model); Person p = new Person() { Name = model.Name, Email = model.Email, Password = model.Password, IsActivated = false }; using (CrdbContext ctx = new CrdbContext()) { PersonBL.CreatePerson(p, ctx); } AppUser appUser = AppUser.FromPerson(p); IdentitySignin(appUser, null, model.RememberMe); if (string.IsNullOrEmpty(model.ReturnUrl)) model.ReturnUrl = Url.Action("Index", "Home"); return Redirect(model.ReturnUrl); }
internal static AppUser FromPerson(Person p) { AppUser retVal = new AppUser(); retVal.Id = p.Id; retVal.Email = p.Email; retVal.Name = p.Name; return retVal; }
public static void CreatePerson(Person person, CrdbContext dbContext) { dbContext.People.Add(person); dbContext.SaveChanges(); }