From 4fd88a39d7fb054776c254adbca0f8061d2c7d7c Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Mon, 25 Mar 2024 17:35:25 -0700 Subject: [PATCH] psp-8133 do not show retired properties unless isretired specified. --- .../backend/dal/Helpers/Extensions/PropertyExtensions.cs | 8 ++++---- .../tests/unit/dal/Repositories/PropertyRepositoryTest.cs | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/backend/dal/Helpers/Extensions/PropertyExtensions.cs b/source/backend/dal/Helpers/Extensions/PropertyExtensions.cs index 4397a70c57..7ea2852b30 100644 --- a/source/backend/dal/Helpers/Extensions/PropertyExtensions.cs +++ b/source/backend/dal/Helpers/Extensions/PropertyExtensions.cs @@ -104,19 +104,19 @@ private static ExpressionStarter GenerateCommonPropertyQuery(Claim ownershipBuilder = isRetired ? PredicateBuilder.New(p => p.IsRetired == true) : PredicateBuilder.New(p => false); if (filter.Ownership.Contains("isCoreInventory")) { - ownershipBuilder = ownershipBuilder.Or(p => p.IsOwned); + ownershipBuilder = ownershipBuilder.Or(p => p.IsOwned && p.IsRetired != true); } if (filter.Ownership.Contains("isPropertyOfInterest")) { - ownershipBuilder = ownershipBuilder.Or(p => p.IsPropertyOfInterest); + ownershipBuilder = ownershipBuilder.Or(p => p.IsPropertyOfInterest && p.IsRetired != true); } if (filter.Ownership.Contains("isOtherInterest")) { - ownershipBuilder = ownershipBuilder.Or(p => p.IsOtherInterest); + ownershipBuilder = ownershipBuilder.Or(p => p.IsOtherInterest && p.IsRetired != true); } if (filter.Ownership.Contains("isDisposed")) { - ownershipBuilder = ownershipBuilder.Or(p => p.IsDisposed); + ownershipBuilder = ownershipBuilder.Or(p => p.IsDisposed && p.IsRetired != true); } } else diff --git a/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs b/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs index f5a08892d7..a6de76a099 100644 --- a/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs +++ b/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs @@ -38,7 +38,7 @@ public class PropertyRepositoryTest new object[] { new PropertyFilter(), 7 }, new object[] { new PropertyFilter(){ Ownership = new List(){"isCoreInventory", "isPropertyOfInterest"}}, 4 }, new object[] { new PropertyFilter(){ Ownership = new List(){"isDisposed"}}, 1 }, - new object[] { new PropertyFilter(){ Ownership = new List(){"isRetired"}}, 1 }, + new object[] { new PropertyFilter(){ Ownership = new List(){"isRetired"}}, 2 }, new object[] { new PropertyFilter(){ Ownership = new List(){"isOtherInterest"}}, 1 }, new object[] { new PropertyFilter(){ Ownership = new List(){"isCoreInventory"}}, 3 }, }; @@ -118,6 +118,9 @@ public void GetPage_Properties(PropertyFilter filter, int expectedCount) testProperty.IsRetired = true; testProperty = init.CreateProperty(33333); testProperty.SurveyPlanNumber = "SP-89TTXY"; + testProperty = init.CreateProperty(44444); + testProperty.IsRetired = true; + testProperty.IsOwned = true; init.SaveChanges();