public ActionResult Edit() { Admin currentAdmin = RepositoryFactory.AdminsRepository. GetAdmin(a => a.Username == User.Identity.Name); AccountModel model = new AccountModel { Username = currentAdmin.Username, ProfileModel = new AdminProfileModel(currentAdmin.Profile) }; return View(model); }
public ActionResult Edit(AccountModel model, String returnUrl) { if (ModelState.IsValid) { Admin currentAdmin = new Admin { Username = User.Identity.Name }; model.ProfileModel.UpdateAdminProfile(currentAdmin.Profile); RepositoryFactory.AdminsRepository.UpdateAdmin(currentAdmin); if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } return RedirectToAction("Details"); } return View(model); }
public ActionResult Create(AccountModel model) { if (ModelState.IsValid) { bool createdSuccessfully; try { WebSecurity.CreateUserAndAccount(model.Username, model.NewPassword); createdSuccessfully = true; } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); createdSuccessfully = false; } if (createdSuccessfully) { Admin adminToUpdate = new Admin { Username = model.Username }; model.ProfileModel.UpdateAdminProfile(adminToUpdate.Profile); RepositoryFactory.AdminsRepository.UpdateAdmin(adminToUpdate); return RedirectToAction("AllAccounts"); } } return View(model); }