/// <summary> /// Called to handle the "delete" action, if supported. /// </summary> /// <param name="items"></param> /// <param name="deletedItems">The list of items that were deleted.</param> /// <param name="failureMessage">The message if there any errors that occurs during deletion.</param> /// <returns>True if items were deleted, false otherwise.</returns> protected override bool DeleteItems(IList <StaffSummary> items, out IList <StaffSummary> deletedItems, out string failureMessage) { failureMessage = null; deletedItems = new List <StaffSummary>(); foreach (StaffSummary item in items) { try { Platform.GetService <IStaffAdminService>( delegate(IStaffAdminService service) { // check if staff has associated user account StaffDetail detail = service.LoadStaffForEdit( new LoadStaffForEditRequest(item.StaffRef)).StaffDetail; if (!string.IsNullOrEmpty(detail.UserName)) { // ask if the account should be deleted too if (this.Host.ShowMessageBox( string.Format(SR.MessageConfirmDeleteAssociatedUserAccount, detail.UserName), MessageBoxActions.YesNo) == DialogBoxAction.Yes) { Platform.GetService <IUserAdminService>( delegate(IUserAdminService userAdminService) { userAdminService.DeleteUser(new DeleteUserRequest(detail.UserName)); }); } else { // not deleting user, but we should update user's display name Platform.GetService <IUserAdminService>( delegate(IUserAdminService userAdminService) { LoadUserForEditResponse editResponse = userAdminService.LoadUserForEdit(new LoadUserForEditRequest(detail.UserName)); UserDetail userDetail = editResponse.UserDetail; userDetail.DisplayName = null; userAdminService.UpdateUser(new UpdateUserRequest(userDetail)); }); } } service.DeleteStaff(new DeleteStaffRequest(item.StaffRef)); }); deletedItems.Add(item); } catch (Exception e) { failureMessage = e.Message; } } return(deletedItems.Count > 0); }
private static bool GetExistingAccount(string account, out UserDetail detail) { try { LoadUserForEditResponse response = null; Platform.GetService <IUserAdminService>( service => response = service.LoadUserForEdit(new LoadUserForEditRequest(account))); detail = response.UserDetail; return(true); } catch (FaultException <RequestValidationException> ) { detail = null; return(false); } }
public override void Start() { // load all auth groups Platform.GetService( delegate(IAuthorityGroupAdminService service) { ListAuthorityGroupsResponse authorityGroupsResponse = service.ListAuthorityGroups(new ListAuthorityGroupsRequest()); _authorityGroups = CollectionUtils.Map( authorityGroupsResponse.AuthorityGroups, delegate(AuthorityGroupSummary summary) { return(new AuthorityGroupTableEntry(summary, OnAuthorityGroupChecked)); }); }); // load user Platform.GetService( delegate(IUserAdminService service) { if (_isNew) { _userDetail = new UserDetail { // Force users to change the password when they log in PasswordExpiryTime = Platform.Time }; } else { LoadUserForEditResponse response = service.LoadUserForEdit(new LoadUserForEditRequest(_userName)); _userDetail = response.UserDetail; } }); InitialiseTable(); base.Start(); }