protected override void ShowEditForm(object sender, UbiquicityEventArg e) { int id = Convert.ToInt32(e.TheObject); Session["Ubiquicity_itemId"] = id; UserManager userManager = new UserManager(); User user = userManager.Get(id); RoleManager roleManager = new RoleManager(); List <Role> unassignedRoles = roleManager.GetUnassignedRole(user); if (userManager.HasErrors) { Alert.Show("Error", userManager.Errors[0].description); } else { if (unassignedRoles == null) { unassignedRoles = new List <Role>(); } //Se guardan en sesiĆ³n para su manejo posterior KeepInSession("granted", user.Roles); KeepInSession("toGrant", unassignedRoles); UCFormUserRole.FillForm(user, unassignedRoles); Session["Ubiquicity_action"] = EDIT; ShowCrudForm(); } }
/// <summary> /// Ejecuta el pasaje de la lista de los disponibles a los asignados. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GrantPermission(object sender, EventArgs e) { List <Role> granted = RetrieveFromSession("granted"); List <Role> toGrant = RetrieveFromSession("toGrant"); int id = int.Parse(Session["Ubiquicity_roleId"].ToString()); SwitchPermission(id, "toGrant", toGrant, "granted", granted); UCFormUserRole.FillForm(granted, toGrant); }