11using System . ComponentModel . DataAnnotations ;
2- using System . Reflection ;
32using Microsoft . Extensions . DependencyInjection ;
43using Microsoft . Extensions . Logging ;
54using Umbraco . Cms . Core . DependencyInjection ;
1413using Umbraco . Cms . Core . Scoping ;
1514using Umbraco . Cms . Core . Services . OperationStatus ;
1615using Umbraco . Extensions ;
17- using DataType = Umbraco . Cms . Core . Models . DataType ;
1816
1917namespace Umbraco . Cms . Core . Services . Implement
2018{
@@ -224,27 +222,29 @@ public IEnumerable<EntityContainer> GetContainers(int[] containerIds)
224222 => GetAsync ( name ) . GetAwaiter ( ) . GetResult ( ) ;
225223
226224 /// <inheritdoc />
227- public async Task < IDataType ? > GetAsync ( string name )
225+ public Task < IDataType ? > GetAsync ( string name )
228226 {
229227 using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
230228 IDataType ? dataType = _dataTypeRepository . Get ( Query < IDataType > ( ) . Where ( x => x . Name == name ) ) ? . FirstOrDefault ( ) ;
231229 ConvertMissingEditorOfDataTypeToLabel ( dataType ) ;
232- return await Task . FromResult ( dataType ) ;
230+
231+ return Task . FromResult ( dataType ) ;
233232 }
234233
235234 /// <inheritdoc />
236235 public Task < IEnumerable < IDataType > > GetAllAsync ( params Guid [ ] keys )
237236 {
238- // Nothing requested, return nothing
239- if ( keys . Any ( ) is false )
237+ using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
238+
239+ IQuery < IDataType > query = Query < IDataType > ( ) ;
240+ if ( keys . Length > 0 )
240241 {
241- return Task . FromResult ( Enumerable . Empty < IDataType > ( ) ) ;
242+ query = query . Where ( x => keys . Contains ( x . Key ) ) ;
242243 }
243244
244- using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
245-
246- IDataType [ ] dataTypes = _dataTypeRepository . Get ( Query < IDataType > ( ) . Where ( x => keys . Contains ( x . Key ) ) ) . ToArray ( ) ;
245+ IDataType [ ] dataTypes = _dataTypeRepository . Get ( query ) . ToArray ( ) ;
247246 ConvertMissingEditorsOfDataTypesToLabels ( dataTypes ) ;
247+
248248 return Task . FromResult < IEnumerable < IDataType > > ( dataTypes ) ;
249249 }
250250
@@ -288,6 +288,7 @@ public Task<PagedModel<IDataType>> FilterAsync(string? name = null, string? edit
288288 using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
289289 IDataType ? dataType = _dataTypeRepository . Get ( id ) ;
290290 ConvertMissingEditorOfDataTypeToLabel ( dataType ) ;
291+
291292 return dataType ;
292293 }
293294
@@ -301,12 +302,13 @@ public Task<PagedModel<IDataType>> FilterAsync(string? name = null, string? edit
301302 => GetAsync ( id ) . GetAwaiter ( ) . GetResult ( ) ;
302303
303304 /// <inheritdoc />
304- public async Task < IDataType ? > GetAsync ( Guid id )
305+ public Task < IDataType ? > GetAsync ( Guid id )
305306 {
306307 using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
307308 IDataType ? dataType = GetDataTypeFromRepository ( id ) ;
308309 ConvertMissingEditorOfDataTypeToLabel ( dataType ) ;
309- return await Task . FromResult ( dataType ) ;
310+
311+ return Task . FromResult ( dataType ) ;
310312 }
311313
312314 /// <summary>
@@ -319,23 +321,25 @@ public IEnumerable<IDataType> GetByEditorAlias(string propertyEditorAlias)
319321 => GetByEditorAliasAsync ( propertyEditorAlias ) . GetAwaiter ( ) . GetResult ( ) ;
320322
321323 /// <inheritdoc />
322- public async Task < IEnumerable < IDataType > > GetByEditorAliasAsync ( string propertyEditorAlias )
324+ public Task < IEnumerable < IDataType > > GetByEditorAliasAsync ( string propertyEditorAlias )
323325 {
324326 using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
325327 IQuery < IDataType > query = Query < IDataType > ( ) . Where ( x => x . EditorAlias == propertyEditorAlias ) ;
326328 IEnumerable < IDataType > dataTypes = _dataTypeRepository . Get ( query ) . ToArray ( ) ;
327329 ConvertMissingEditorsOfDataTypesToLabels ( dataTypes ) ;
328- return await Task . FromResult ( dataTypes ) ;
330+
331+ return Task . FromResult ( dataTypes ) ;
329332 }
330333
331334 /// <inheritdoc />
332- public async Task < IEnumerable < IDataType > > GetByEditorUiAlias ( string editorUiAlias )
335+ public Task < IEnumerable < IDataType > > GetByEditorUiAlias ( string editorUiAlias )
333336 {
334337 using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
335338 IQuery < IDataType > query = Query < IDataType > ( ) . Where ( x => x . EditorUiAlias == editorUiAlias ) ;
336339 IEnumerable < IDataType > dataTypes = _dataTypeRepository . Get ( query ) . ToArray ( ) ;
337340 ConvertMissingEditorsOfDataTypesToLabels ( dataTypes ) ;
338- return await Task . FromResult ( dataTypes ) ;
341+
342+ return Task . FromResult ( dataTypes ) ;
339343 }
340344
341345 /// <summary>
@@ -347,8 +351,8 @@ public IEnumerable<IDataType> GetAll(params int[] ids)
347351 {
348352 using ICoreScope scope = ScopeProvider . CreateCoreScope ( autoComplete : true ) ;
349353 IEnumerable < IDataType > dataTypes = _dataTypeRepository . GetMany ( ids ) . ToArray ( ) ;
350-
351354 ConvertMissingEditorsOfDataTypesToLabels ( dataTypes ) ;
355+
352356 return dataTypes ;
353357 }
354358
@@ -366,8 +370,7 @@ private void ConvertMissingEditorsOfDataTypesToLabels(IEnumerable<IDataType> dat
366370 {
367371 // Any data types that don't have an associated editor are created of a specific type.
368372 // We convert them to labels to make clear to the user why the data type cannot be used.
369- IEnumerable < IDataType > dataTypesWithMissingEditors = dataTypes
370- . Where ( x => x . Editor is MissingPropertyEditor ) ;
373+ IEnumerable < IDataType > dataTypesWithMissingEditors = dataTypes . Where ( x => x . Editor is MissingPropertyEditor ) ;
371374 foreach ( IDataType dataType in dataTypesWithMissingEditors )
372375 {
373376 dataType . Editor = new LabelPropertyEditor ( _dataValueEditorFactory , _ioHelper ) ;
@@ -398,7 +401,7 @@ private void ConvertMissingEditorsOfDataTypesToLabels(IEnumerable<IDataType> dat
398401 DataTypeOperationStatus . Success => OperationResult . Attempt . Succeed ( MoveOperationStatusType . Success , evtMsgs ) ,
399402 DataTypeOperationStatus . CancelledByNotification => OperationResult . Attempt . Fail ( MoveOperationStatusType . FailedCancelledByEvent , evtMsgs ) ,
400403 DataTypeOperationStatus . ParentNotFound => OperationResult . Attempt . Fail ( MoveOperationStatusType . FailedParentNotFound , evtMsgs ) ,
401- _ => OperationResult . Attempt . Fail < MoveOperationStatusType > ( MoveOperationStatusType . FailedNotAllowedByPath , evtMsgs , new InvalidOperationException ( $ "Invalid operation status: { result . Status } ") ) ,
404+ _ => OperationResult . Attempt . Fail < MoveOperationStatusType > ( MoveOperationStatusType . FailedNotAllowedByPath , evtMsgs , new InvalidOperationException ( $ "Invalid operation status: { result . Status } ") ) ,
402405 } ;
403406 }
404407
@@ -448,9 +451,7 @@ public async Task<Attempt<IDataType, DataTypeOperationStatus>> MoveAsync(IDataTy
448451
449452 [ Obsolete ( "Use the method which specifies the userId parameter" ) ]
450453 public Attempt < OperationResult < MoveOperationStatusType , IDataType > ? > Copy ( IDataType copying , int containerId )
451- {
452- return Copy ( copying , containerId , Constants . Security . SuperUserId ) ;
453- }
454+ => Copy ( copying , containerId , Constants . Security . SuperUserId ) ;
454455
455456 public Attempt < OperationResult < MoveOperationStatusType , IDataType > ? > Copy ( IDataType copying , int containerId , int userId = Constants . Security . SuperUserId )
456457 {
@@ -671,7 +672,6 @@ public void Delete(IDataType dataType, int userId = Constants.Security.SuperUser
671672
672673 scope . Notifications . Publish ( new DataTypeDeletedNotification ( dataType , eventMessages ) . WithStateFrom ( deletingDataTypeNotification ) ) ;
673674
674-
675675 var currentUserId = await _userIdKeyResolver . GetAsync ( userKey ) ;
676676 Audit ( AuditType . Delete , currentUserId , dataType . Id ) ;
677677
0 commit comments