From e7906eb6927d43f80df9d8c0d80b22ef3b022e00 Mon Sep 17 00:00:00 2001 From: Smith Date: Fri, 20 Oct 2023 15:36:58 -0700 Subject: [PATCH] psp-7034 add warning message when attempting to remove an acquisition file property associated to other sub-entities within that file. --- source/backend/api/Services/AcquisitionFileService.cs | 4 ++-- .../dal/Repositories/AcquisitionFilePropertyRepository.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/backend/api/Services/AcquisitionFileService.cs b/source/backend/api/Services/AcquisitionFileService.cs index 5661865dbb..420822ac90 100644 --- a/source/backend/api/Services/AcquisitionFileService.cs +++ b/source/backend/api/Services/AcquisitionFileService.cs @@ -294,9 +294,9 @@ public PimsAcquisitionFile UpdateProperties(PimsAcquisitionFile acquisitionFile, foreach (var deletedProperty in differenceSet) { var acqFileProperties = _acquisitionFilePropertyRepository.GetPropertiesByAcquisitionFileId(acquisitionFile.Internal_Id).FirstOrDefault(ap => ap.PropertyId == deletedProperty.PropertyId); - if (acqFileProperties.PimsTakes.Any()) + if (acqFileProperties.PimsTakes.Any() || acqFileProperties.PimsInthldrPropInterests.Any()) { - throw new BusinessRuleViolationException(); + throw new BusinessRuleViolationException("You must remove all takes and interest holders from an acquisition file property before removing that property from an acquisition file"); } _acquisitionFilePropertyRepository.Delete(deletedProperty); if (deletedProperty.Property.IsPropertyOfInterest.HasValue && deletedProperty.Property.IsPropertyOfInterest.Value) diff --git a/source/backend/dal/Repositories/AcquisitionFilePropertyRepository.cs b/source/backend/dal/Repositories/AcquisitionFilePropertyRepository.cs index 6c5314795c..3437e3b2fe 100644 --- a/source/backend/dal/Repositories/AcquisitionFilePropertyRepository.cs +++ b/source/backend/dal/Repositories/AcquisitionFilePropertyRepository.cs @@ -6,7 +6,6 @@ using Pims.Core.Extensions; using Pims.Dal.Entities; using Pims.Dal.Helpers.Extensions; -using Pims.Dal.Security; namespace Pims.Dal.Repositories { @@ -37,6 +36,7 @@ public List GetPropertiesByAcquisitionFileId(long a return Context.PimsPropertyAcquisitionFiles .Where(x => x.AcquisitionFileId == acquisitionFileId) .Include(rp => rp.PimsTakes) + .Include(ap => ap.PimsInthldrPropInterests) .Include(rp => rp.Property) .ThenInclude(rp => rp.RegionCodeNavigation) .Include(rp => rp.Property)