Пример #1
0
 public ActionResult Edit(string userName)
 {
     var user = Membership.GetUser(userName, false);
     if (user == null) return this.HttpNotFound();
     var model = new UserEditViewModel {
         EmailAddress = user.Email,
         IsApproved = user.IsApproved,
     };
     ViewBag.Title = string.Format("Editace uživatele '{0}'", user.UserName);
     ViewBag.CancelAction = "Index";
     return View("~/Views/Shared/UniversalEditor.cshtml", model);
 }
Пример #2
0
 public ActionResult Edit(UserEditViewModel model, string userName)
 {
     var user = Membership.GetUser(userName, false);
     if (user == null) return this.HttpNotFound();
     if (this.TryUpdateModel(model)) {
         user.Email = model.EmailAddress;
         user.IsApproved = model.IsApproved;
         Membership.UpdateUser(user);
         if (!string.IsNullOrWhiteSpace(model.NewPassword)) {
             var tempPassword = user.ResetPassword();
             user.ChangePassword(tempPassword, model.NewPassword);
         }
         return this.RedirectToAction("Index");
     }
     ViewBag.Title = string.Format("Editace uživatele '{0}'", user.UserName);
     ViewBag.CancelAction = "Index";
     return View("~/Views/Shared/UniversalEditor.cshtml", model);
 }