public ActionResult Edit(long id) { SubjectManager subjectManager = new SubjectManager(); User user = subjectManager.GetUserById(id); return PartialView("_EditPartial", UserEditModel.Convert(user)); }
public ActionResult Edit(UserEditModel model) { if (ModelState.IsValid) { SubjectManager subjectManager = new SubjectManager(); User user = subjectManager.GetUserById(model.UserId); if (model.Password == model.ConfirmPassword && model.Password != null) { subjectManager.ChangePassword(user.Id, model.Password); } user.FullName = model.FullName; user.Email = model.Email; user.IsApproved = model.IsApproved; user.IsBlocked = model.IsBlocked; user.IsLockedOut = model.IsLockedOut; // removing long[] groups = user.Groups.Select(g => g.Id).ToArray(); foreach (long groupId in groups) { subjectManager.RemoveUserFromGroup(user.Id, groupId); } //adding if (Session["Groups"] != null) { foreach (UserMembershipGridRowModel group in (UserMembershipGridRowModel[]) Session["Groups"]) { if (group.IsUserInGroup) { subjectManager.AddUserToGroup(user.Id, group.Id); } } } subjectManager.UpdateUser(user); return Json(new { success = true }); } else { return PartialView("_EditPartial", model); } }
public ActionResult Membership_Select(long id, long[] selectedGroups) { SubjectManager subjectManager = new SubjectManager(); List<UserMembershipGridRowModel> groups = new List<UserMembershipGridRowModel>(); if (selectedGroups != null) { groups = subjectManager.GetAllGroups().Select(g => UserMembershipGridRowModel.Convert(g, selectedGroups.Contains(g.Id))).ToList(); } else { User user = subjectManager.GetUserById(id); groups = subjectManager.GetAllGroups().Select(g => UserMembershipGridRowModel.Convert(g, g.Users.Any(u => u.Id == id))).ToList(); } return View(new GridModel<UserMembershipGridRowModel> { Data = groups }); }
public ActionResult MyAccount(MyAccountModel model) { if (!ModelState.IsValid) return View("MyAccount", model); SubjectManager subjectManager = new SubjectManager(); User user = subjectManager.GetUserById(model.UserId); if (model.Password == model.ConfirmPassword && model.Password != null) { subjectManager.ChangePassword(user.Id, model.Password); } if (model.SecurityAnswer != null) { subjectManager.ChangeSecurityQuestionAndSecurityAnswer(user.Id, model.SecurityQuestionId, model.SecurityAnswer); } user.Email = model.Email; user.FullName = model.FullName; subjectManager.UpdateUser(user); return RedirectToAction("Index", "Home", new { area = "" }); }