From abb23dac616989e5f2bda04c12e6d03aea4cf384 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Mon, 16 Oct 2023 17:07:13 +1000 Subject: [PATCH] Finish changing to property --- src/Api/Controllers/CollectionsController.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Api/Controllers/CollectionsController.cs b/src/Api/Controllers/CollectionsController.cs index b6a24ef543..9a5a12cff9 100644 --- a/src/Api/Controllers/CollectionsController.cs +++ b/src/Api/Controllers/CollectionsController.cs @@ -47,6 +47,8 @@ public class CollectionsController : Controller _featureService = featureService; } + private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); + [HttpGet("{id}")] public async Task Get(Guid orgId, Guid id) { @@ -157,7 +159,7 @@ public class CollectionsController : Controller { var collection = model.ToCollection(orgId); - var authorized = FlexibleCollectionsIsEnabled() + var authorized = FlexibleCollectionsIsEnabled ? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Create)).Succeeded : await CanCreateCollection(orgId, collection.Id) || await CanEditCollectionAsync(orgId, collection.Id); if (!authorized) @@ -233,7 +235,7 @@ public class CollectionsController : Controller { var collection = await GetCollectionAsync(id, orgId); - var authorized = FlexibleCollectionsIsEnabled() + var authorized = FlexibleCollectionsIsEnabled ? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Delete)).Succeeded : await CanDeleteCollectionAsync(orgId, id); if (!authorized) @@ -248,7 +250,7 @@ public class CollectionsController : Controller [HttpPost("delete")] public async Task DeleteMany(Guid orgId, [FromBody] CollectionBulkDeleteRequestModel model) { - if (FlexibleCollectionsIsEnabled()) + if (FlexibleCollectionsIsEnabled) { // New flexible collections logic var collections = await _collectionRepository.GetManyByManyIdsAsync(model.Ids); @@ -308,11 +310,9 @@ public class CollectionsController : Controller return collection; } - private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext); - private void DeprecatedPermissionsGuard() { - if (FlexibleCollectionsIsEnabled()) + if (FlexibleCollectionsIsEnabled) { throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF."); }