Skip to content

Commit

Permalink
psp-7034 add warning message when attempting to remove an acquisition…
Browse files Browse the repository at this point in the history
… file property associated to other sub-entities within that file.
  • Loading branch information
Smith authored and Smith committed Oct 20, 2023
1 parent d064ab5 commit e7906eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Pims.Core.Extensions;
using Pims.Dal.Entities;
using Pims.Dal.Helpers.Extensions;

Check warning on line 8 in source/backend/dal/Repositories/AcquisitionFilePropertyRepository.cs

View workflow job for this annotation

GitHub Actions / build-backend

Remove this unnecessary 'using'.
using Pims.Dal.Security;

namespace Pims.Dal.Repositories
{
Expand Down Expand Up @@ -37,6 +36,7 @@ public List<PimsPropertyAcquisitionFile> 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)
Expand Down

0 comments on commit e7906eb

Please sign in to comment.