Changeset 4726 for branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/UserManagement.cs
- Timestamp:
- 11/06/10 09:56:39 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/UserManagement.cs
r4647 r4726 16 16 AuthenticationService service; 17 17 Guid applicationId = new Guid("04371D20-8FD4-4607-A632-42C8D186786B"); 18 18 19 19 20 public UserManagement() … … 29 30 if (service != null) 30 31 { 31 this.bsRoles.DataSource = service.GetRoles(applicationId);32 this.bsUsers.DataSource = service.GetUsers(applicationId);33 32 33 34 RefreshApplicationlist(); 35 } 36 } 37 38 private void RefreshApplicationlist() 39 { 40 this.bsApplications.DataSource = service.GetApplications(); 41 RefreshRolelist(); 42 RefreshUserlist(); 43 } 44 45 private void RefreshRolelist() 46 { 47 this.bsRoles.DataSource = service.GetRoles(applicationId); 48 } 49 50 private void RefreshUserlist() 51 { 52 this.bsUsers.DataSource = service.GetUsers(applicationId); 53 } 54 55 private void RefreshRoleUserlist(Guid roleId) 56 { 57 this.bsRoleUsers.DataSource = service.GetUsersInRole(roleId); 58 } 59 60 private void dgvUsers_SelectionChanged(object sender, EventArgs e) 61 { 62 // show detail 63 if(dgvUsers.SelectedRows.Count == 1){ 64 User user = (User)dgvUsers.SelectedRows[0].DataBoundItem; 65 bsUser.DataSource = user; 66 bsUserRoles.DataSource = service.GetRolesForUser(user.UserId); 67 tcUser.Enabled = false; 68 } 69 } 70 71 private void dgvRoles_SelectionChanged(object sender, EventArgs e) 72 { 73 if (dgvRoles.SelectedRows.Count == 1) 74 { 75 Role role = (Role) dgvRoles.SelectedRows[0].DataBoundItem; 76 bsRole.DataSource = role; 77 IEnumerable<User> _l = service.GetUsersInRole(role.RoleId); 78 bsRoleUsers.DataSource = service.GetUsersInRole(role.RoleId); 79 btnDeleteRole.Enabled = true; 80 tcRole.Enabled = true; 81 } 82 } 83 84 private void btnNewRole_Click(object sender, EventArgs e) 85 { 86 // new Role 87 Role role = new Role(); 88 role.ApplicationId = applicationId; 89 bsRole.DataSource = role; 90 tcRole.Enabled = true; 91 } 92 93 private void btnNewUser_Click(object sender, EventArgs e) 94 { 95 User user = new User(); 96 user.ApplicationId = applicationId; 97 bsUser.DataSource = user; 98 tcUser.Enabled = true; 99 } 100 101 private void btnSaveUser_Click(object sender, EventArgs e) 102 { 103 User user = (User)bsUser.DataSource; 104 tcUser.Enabled = false; 105 service.InsertUser(user); 106 RefreshUserlist(); 107 108 } 109 110 private void btnSaveRole_Click(object sender, EventArgs e) 111 { 112 Role role = (Role)bsRole.DataSource; 113 role.ApplicationId = applicationId; 114 service.InsertRole(role); 115 tcRole.Enabled = false; 116 RefreshRolelist(); 117 } 118 119 120 121 private void btnAddUserToRole_Click(object sender, EventArgs e) 122 { 123 if (dgvRoleAvailableUsers.SelectedRows.Count == 1) 124 { 125 User user = (User)dgvRoleAvailableUsers.SelectedRows[0].DataBoundItem; 126 Role role = (Role)bsRole.DataSource; 127 role.ApplicationId = applicationId; 128 user.ApplicationId = applicationId; 129 service.AddUserToRole(role.RoleId, user.UserId); 130 RefreshRoleUserlist(role.RoleId); 131 } 132 } 133 134 private void btnDeleteRole_Click(object sender, EventArgs e) 135 { 136 if (dgvRoles.SelectedRows.Count == 1) 137 { 138 Role role = (Role)dgvRoles.SelectedRows[0].DataBoundItem; 139 service.DeleteRole(role.RoleId); 140 RefreshRolelist(); 141 } 142 } 143 144 private void btnRemoveUserFromRole_Click(object sender, EventArgs e) 145 { 146 // remove from role .. 147 if (dgvRoleAssignedUsers.SelectedRows.Count == 1) 148 { 149 User user = (User)dgvRoleAssignedUsers.SelectedRows[0].DataBoundItem; 150 Role role = (Role)bsRole.DataSource; 151 152 service.RemoveUserFromRole(role.RoleId, user.UserId); 153 RefreshRoleUserlist(role.RoleId); 154 } 155 } 156 157 private void cbxApplication_SelectedIndexChanged(object sender, EventArgs e) 158 { 159 HeuristicLab.Services.Authentication.DataTransfer.Application application = (HeuristicLab.Services.Authentication.DataTransfer.Application)cbxApplication.SelectedItem; 160 if (application != null) 161 { 162 applicationId = application.ApplicationId; 163 RefreshApplicationlist(); 164 } 165 166 } 167 168 private void btnDeleteUser_Click(object sender, EventArgs e) 169 { 170 if (dgvUsers.SelectedRows.Count == 1) 171 { 172 User user = (User)dgvUsers.SelectedRows[0].DataBoundItem; 173 if (user != null) 174 { 175 service.DeleteUser(user.UserId); 176 RefreshUserlist(); 177 } 34 178 } 35 179 }
Note: See TracChangeset
for help on using the changeset viewer.