public ActionResult EditPost(int? userId, int RoleID) { if (userId == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } UserManagerServices services = new UserManagerServices(); T_UserProfile userProfile = services.GetByID((int)userId); if (TryUpdateModel(userProfile, "", new string[] { "Username", "Fullname", "Email", "Mobile", "Enabled" })) { try { ReturnValue<bool> ret = services.UpdateT_UserProfile(userProfile); //Update role services.SetUserInrole(userProfile.UserId, RoleID); if (ret.RetValue) { return RedirectToAction("List", "UserManager"); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } } webpages_Roles Role = services.GetRoleByUserId((int)userId); if (Role != null) { PopulateRole(Role.RoleId); } else { PopulateRole(null); } return View("Edit", userProfile); }
public PartialViewResult GetRole(int? userId) { if (userId.HasValue) { UserManagerServices services = new UserManagerServices(); webpages_Roles RoleList = services.GetRoleByUserId((int)userId); if (RoleList != null) { return PartialView("GetRole", RoleList.RoleName); } } return PartialView(); }
public ActionResult Edit(int? userId) { if (userId == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } UserManagerServices services = new UserManagerServices(); T_UserProfile userProfile = services.GetByID((int)userId); webpages_Roles Role = services.GetRoleByUserId((int)userId); if(Role != null) { PopulateRole(Role.RoleId); } else { PopulateRole(null); } if (userProfile == null) { return HttpNotFound(); } return View("Edit", userProfile); }