@@ -109,11 +109,10 @@ public async Task Init()
109109 await Load ( ) ;
110110 }
111111
112-
113112 [ RelayCommand ]
114113 private async Task Load ( )
115114 {
116- DirectoryObjects = await IsBusyWrapper1 ( async ( ) => SelectedEntity switch
115+ await IsBusyWrapper ( async ( ) => SelectedEntity switch
117116 {
118117 "Users" => await graphDataService . GetUserCollectionAsync ( SplittedSelect , Filter , SplittedOrderBy , Search ) ,
119118 "Groups" => await graphDataService . GetGroupCollectionAsync ( SplittedSelect , Filter , SplittedOrderBy , Search ) ,
@@ -130,38 +129,39 @@ private async Task DrillDown()
130129 {
131130 ArgumentNullException . ThrowIfNull ( SelectedObject ) ;
132131
133- DirectoryObjects = await IsBusyWrapper1 ( async ( ) =>
132+ await IsBusyWrapper ( async ( ) =>
134133 {
135134 OrderBy = string . Empty ;
136135 Filter = string . Empty ;
137136 Search = string . Empty ;
138137
139- return SelectedEntity switch
138+ return DirectoryObjects switch
140139 {
141- "Users" => await graphDataService . GetTransitiveMemberOfAsGroupCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
142- "Groups" => await graphDataService . GetTransitiveMembersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
143- "Applications" => await graphDataService . GetApplicationOwnersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
144- "ServicePrincipals" => await graphDataService . GetServicePrincipalOwnersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
145- "Devices" => await graphDataService . GetDeviceOwnersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
146- _ => throw new NotImplementedException ( "Can't find selected entity " )
140+ UserCollectionResponse userCollection => await graphDataService . GetTransitiveMemberOfAsGroupCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
141+ GroupCollectionResponse groupCollection => await graphDataService . GetTransitiveMembersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
142+ ApplicationCollectionResponse applicationCollection => await graphDataService . GetApplicationOwnersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
143+ ServicePrincipalCollectionResponse servicePrincipalCollection => await graphDataService . GetServicePrincipalOwnersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
144+ DeviceCollectionResponse deviceCollection => await graphDataService . GetDeviceOwnersAsUserCollectionAsync ( SelectedObject . Id ! , SplittedSelect ) ,
145+ _ => throw new NotImplementedException ( "Can't find Entity Type " )
147146 } ;
148147 } ) ;
149148 }
150149
151150 private bool CanGoNextPage => DirectoryObjects ? . OdataNextLink is not null ;
152151 [ RelayCommand ( CanExecute = nameof ( CanGoNextPage ) ) ]
153- private async Task LoadNextPage ( )
152+ private Task LoadNextPage ( )
154153 {
155- //DirectoryObjects = await graphDataService.GetNextPageAsync(DirectoryObjects);
156- DirectoryObjects = DirectoryObjects switch
154+ //return IsBusyWrapper(() => graphDataService.GetNextPageAsync(DirectoryObjects));
155+
156+ return IsBusyWrapper ( async ( ) => DirectoryObjects switch
157157 {
158158 UserCollectionResponse userCollection => await graphDataService . GetNextPageAsync ( userCollection ) ,
159159 GroupCollectionResponse groupCollection => await graphDataService . GetNextPageAsync ( groupCollection ) ,
160160 ApplicationCollectionResponse applicationCollection => await graphDataService . GetNextPageAsync ( applicationCollection ) ,
161161 ServicePrincipalCollectionResponse servicePrincipalCollection => await graphDataService . GetNextPageAsync ( servicePrincipalCollection ) ,
162162 DeviceCollectionResponse deviceCollection => await graphDataService . GetNextPageAsync ( deviceCollection ) ,
163- _ => throw new NotImplementedException ( "Can't find selected entity " )
164- } ;
163+ _ => throw new NotImplementedException ( "Can't find Entity Type " )
164+ } ) ;
165165 }
166166
167167 [ RelayCommand ]
@@ -199,48 +199,9 @@ private void Logout()
199199 authService . Logout ( ) ;
200200 App . Current . Shutdown ( ) ;
201201 }
202- private async Task < BaseCollectionPaginationCountResponse ? > IsBusyWrapper1 ( Func < Task < BaseCollectionPaginationCountResponse ? > > getDirectoryObjects )
203- {
204- IsBusy = true ;
205- _stopWatch . Restart ( ) ;
206202
207- // Sending message to generate DataGridColumns according to the selected properties
208- WeakReferenceMessenger . Default . Send ( SplittedSelect ) ;
209- try
210- {
211- return await getDirectoryObjects ( ) ;
212-
213- //SelectedEntity = DirectoryObjects switch
214- //{
215- // UserCollectionResponse => "Users",
216- // GroupCollectionResponse => "Groups",
217- // ApplicationCollectionResponse => "Applications",
218- // ServicePrincipalCollectionResponse => "ServicePrincipals",
219- // DeviceCollectionResponse => "Devices",
220- // _ => SelectedEntity,
221- //};
222- }
223- catch ( ODataError ex )
224- {
225- Task . Run ( ( ) => System . Windows . MessageBox . Show ( ex . Message , ex . Error ? . Message ) ) . Await ( ) ;
226- return null ;
227- }
228- catch ( ApiException ex )
229- {
230- Task . Run ( ( ) => System . Windows . MessageBox . Show ( ex . Message , ex . Source ) ) . Await ( ) ;
231- return null ;
232- }
233- finally
234- {
235- _stopWatch . Stop ( ) ;
236- OnPropertyChanged ( nameof ( ElapsedMs ) ) ;
237- OnPropertyChanged ( nameof ( LastUrl ) ) ;
238- IsBusy = false ;
239- }
240-
241- }
242203
243- private async Task IsBusyWrapper ( Task < BaseCollectionPaginationCountResponse > getDirectoryObjects )
204+ private async Task IsBusyWrapper ( Func < Task < BaseCollectionPaginationCountResponse ? > > getDirectoryObjects )
244205 {
245206 IsBusy = true ;
246207 _stopWatch . Restart ( ) ;
@@ -250,7 +211,7 @@ private async Task IsBusyWrapper(Task<BaseCollectionPaginationCountResponse> get
250211
251212 try
252213 {
253- DirectoryObjects = await getDirectoryObjects ;
214+ DirectoryObjects = await getDirectoryObjects ( ) ;
254215
255216 SelectedEntity = DirectoryObjects switch
256217 {
0 commit comments