public ActionResult AddAccount(AddNewAccount accounts) { if (ModelState.IsValid) { string hashPasword = HashPassword.HashThePassword(accounts.Password); Account account = new Account(accounts.Id, accounts.FirstName, accounts.LastName, accounts.EmailAddress, hashPasword, accounts.AccesTo); repository.AddAccount(account); FormsAuthentication.SetAuthCookie(account.EmailAddress, false); Session["loggedin_account"] = account; return RedirectToAction("Index"); } else { return View(accounts); } }
public void AddAccount(Account account) { ctx.Accounts.Add(account); ctx.SaveChanges(); }