diff --git a/.github/workflows/app-react.yml b/.github/workflows/app-react.yml
index 108185bb5d..a71995706e 100644
--- a/.github/workflows/app-react.yml
+++ b/.github/workflows/app-react.yml
@@ -52,7 +52,7 @@ jobs:
- run: npm run build --if-present
working-directory: ${{env.working-directory}}
- - run: npm run coverage -- --maxWorkers=2
+ - run: npm run coverage -- --bail 1 --maxWorkers 2 --minWorkers 2
working-directory: ${{env.working-directory}}
env:
REACT_APP_TENANT: MOTI
diff --git a/source/backend/api/Areas/Takes/Controllers/TakeController.cs b/source/backend/api/Areas/Takes/Controllers/TakeController.cs
index 6061efe24c..162dffc5c4 100644
--- a/source/backend/api/Areas/Takes/Controllers/TakeController.cs
+++ b/source/backend/api/Areas/Takes/Controllers/TakeController.cs
@@ -1,15 +1,18 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
+using Pims.Api.Helpers.Exceptions;
using Pims.Api.Models.Concepts.Take;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Dal.Entities;
+using Pims.Dal.Exceptions;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;
@@ -104,28 +107,98 @@ public IActionResult GetTakesByPropertyId([FromRoute] long fileId, [FromRoute] l
}
///
- /// Update the list of takes associated to a property within an acquisition file.
+ /// Add the passed take to the acquisition property with the given id.
///
///
- [HttpPut("acquisition/property/{acquisitionFilePropertyId:long}")]
+ [HttpPost("acquisition/property/{acquisitionFilePropertyId:long}/takes")]
[HasPermission(Permissions.AcquisitionFileEdit, Permissions.PropertyEdit)]
[Produces("application/json")]
- [ProducesResponseType(typeof(IEnumerable), 200)]
+ [ProducesResponseType(typeof(TakeModel), 201)]
+ [SwaggerOperation(Tags = new[] { "take" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult AddAcquisitionPropertyTake(long acquisitionFilePropertyId, [FromBody] TakeModel take)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(TakeController),
+ nameof(AddAcquisitionPropertyTake),
+ User.GetUsername(),
+ DateTime.Now);
+
+ if (acquisitionFilePropertyId != take.PropertyAcquisitionFileId)
+ {
+ throw new BadRequestException("Invalid acquisition file property id.");
+ }
+
+ _logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());
+
+ var addedTake = _takeService.AddAcquisitionPropertyTake(acquisitionFilePropertyId, _mapper.Map(take));
+ return new JsonResult(_mapper.Map(addedTake));
+ }
+
+ ///
+ /// Update a take with the given take and acquisition file property id with the passed take.
+ ///
+ ///
+ [HttpPut("acquisition/property/{acquisitionFilePropertyId:long}/takes/{takeId:long}")]
+ [HasPermission(Permissions.AcquisitionFileEdit, Permissions.PropertyEdit)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(TakeModel), 200)]
[SwaggerOperation(Tags = new[] { "take" })]
[TypeFilter(typeof(NullJsonResultFilter))]
- public IActionResult UpdateAcquisitionPropertyTakes(long acquisitionFilePropertyId, [FromBody] IEnumerable takes)
+ public IActionResult UpdateAcquisitionPropertyTake(long acquisitionFilePropertyId, long takeId, [FromBody] TakeModel take)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(TakeController),
- nameof(UpdateAcquisitionPropertyTakes),
+ nameof(UpdateAcquisitionPropertyTake),
User.GetUsername(),
DateTime.Now);
+ if (acquisitionFilePropertyId != take.PropertyAcquisitionFileId)
+ {
+ throw new BadRequestException("Invalid acquisition file property id.");
+ }
+ else if (takeId != take.Id)
+ {
+ throw new BadRequestException("Invalid take id.");
+ }
+
_logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());
- var updatedTakes = _takeService.UpdateAcquisitionPropertyTakes(acquisitionFilePropertyId, _mapper.Map>(takes));
- return new JsonResult(_mapper.Map>(updatedTakes));
+ var updatedTake = _takeService.UpdateAcquisitionPropertyTake(acquisitionFilePropertyId, _mapper.Map(take));
+ return new JsonResult(_mapper.Map(updatedTake));
+ }
+
+ ///
+ /// Delete a take with the given take id and acquisition file property id.
+ ///
+ [HttpDelete("acquisition/property/{acquisitionFilePropertyId:long}/takes/{takeId:long}")]
+ [HasPermission(Permissions.AcquisitionFileEdit, Permissions.PropertyEdit)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(void), 200)]
+ [SwaggerOperation(Tags = new[] { "take" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public void DeleteAcquisitionPropertyTake(long acquisitionFilePropertyId, long takeId, [FromQuery] string[] userOverrideCodes)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(TakeController),
+ nameof(DeleteAcquisitionPropertyTake),
+ User.GetUsername(),
+ DateTime.Now);
+
+ _logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());
+ var existingTake = _takeService.GetById(takeId);
+ if (existingTake.PropertyAcquisitionFileId != acquisitionFilePropertyId)
+ {
+ throw new BadRequestException("Invalid acquisition file property id.");
+ }
+ var deleted = _takeService.DeleteAcquisitionPropertyTake(takeId, userOverrideCodes.Select(oc => UserOverrideCode.Parse(oc)));
+ if (!deleted)
+ {
+ throw new InvalidOperationException($"Failed to delete take {takeId}.");
+ }
}
///
@@ -152,6 +225,34 @@ public IActionResult GetTakesCountByPropertyId([FromRoute] long propertyId)
return new JsonResult(count);
}
+ ///
+ /// GGet a take by id.
+ ///
+ ///
+ [HttpGet("acquisition/property/{acquisitionFilePropertyId:long}/takes/{takeId:long}")]
+ [HasPermission(Permissions.AcquisitionFileView, Permissions.PropertyView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(int), 200)]
+ [SwaggerOperation(Tags = new[] { "take" })]
+ public IActionResult GetTakeByPropertyFileId(long acquisitionFilePropertyId, long takeId)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(TakeController),
+ nameof(GetTakesCountByPropertyId),
+ User.GetUsername(),
+ DateTime.Now);
+
+ _logger.LogInformation("Dispatching to service: {Service}", _takeService.GetType());
+
+ var take = _takeService.GetById(takeId);
+ if(take.PropertyAcquisitionFileId != acquisitionFilePropertyId)
+ {
+ throw new BadRequestException("Invalid acquisition file property id.");
+ }
+ return new JsonResult(_mapper.Map(take));
+ }
+
#endregion
}
}
diff --git a/source/backend/api/Constants/EnumDispositionFileStatusTypeCode.cs b/source/backend/api/Constants/EnumDispositionFileStatusTypeCode.cs
deleted file mode 100644
index 4f562bc2ce..0000000000
--- a/source/backend/api/Constants/EnumDispositionFileStatusTypeCode.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Runtime.Serialization;
-
-namespace Pims.Api.Constants
-{
- public enum EnumDispositionFileStatusTypeCode
- {
- [EnumMember(Value = "ACTIVE")]
- ACTIVE,
-
- [EnumMember(Value = "ARCHIVED")]
- ARCHIVED,
-
- [EnumMember(Value = "CANCELLED")]
- CANCELLED,
-
- [EnumMember(Value = "COMPLETE")]
- COMPLETE,
-
- [EnumMember(Value = "DRAFT")]
- DRAFT,
-
- [EnumMember(Value = "HOLD")]
- HOLD,
- }
-}
diff --git a/source/backend/api/Pims.Api.csproj b/source/backend/api/Pims.Api.csproj
index 8faccb2c3e..15b43eb11b 100644
--- a/source/backend/api/Pims.Api.csproj
+++ b/source/backend/api/Pims.Api.csproj
@@ -2,9 +2,9 @@
0ef6255f-9ea0-49ec-8c65-c172304b4926
- 5.2.0-78.19
- 5.2.0-78.19
- 5.2.0.78
+ 5.2.0-79.10
+ 5.2.0-79.10
+ 5.2.0.79true16BC0468-78F6-4C91-87DA-7403C919E646net8.0
diff --git a/source/backend/api/Services/AcquisitionFileService.cs b/source/backend/api/Services/AcquisitionFileService.cs
index 3008693cec..d2b0118a32 100644
--- a/source/backend/api/Services/AcquisitionFileService.cs
+++ b/source/backend/api/Services/AcquisitionFileService.cs
@@ -124,7 +124,7 @@ public List GetAcquisitionFileExport(AcquisitionFilt
FileFunding = fileProperty.file.AcquisitionFundingTypeCodeNavigation is not null ? fileProperty.file.AcquisitionFundingTypeCodeNavigation.Description : string.Empty,
FileAssignedDate = fileProperty.file.AssignedDate.HasValue ? fileProperty.file.AssignedDate.Value.ToString("dd-MMM-yyyy") : string.Empty,
FileDeliveryDate = fileProperty.file.DeliveryDate.HasValue ? fileProperty.file.DeliveryDate.Value.ToString("dd-MMM-yyyy") : string.Empty,
- FileAcquisitionCompleted = fileProperty.file.CompletionDate.HasValue ? fileProperty.file.CompletionDate.Value.ToString("dd-MMM-yyyy") : string.Empty,
+ //FileAcquisitionCompleted = fileProperty.file.CompletionDate.HasValue ? fileProperty.file.CompletionDate.Value.ToString("dd-MMM-yyyy") : string.Empty, TODO: Fix mappings
FilePhysicalStatus = fileProperty.file.AcqPhysFileStatusTypeCodeNavigation is not null ? fileProperty.file.AcqPhysFileStatusTypeCodeNavigation.Description : string.Empty,
FileAcquisitionType = fileProperty.file.AcquisitionTypeCodeNavigation is not null ? fileProperty.file.AcquisitionTypeCodeNavigation.Description : string.Empty,
FileAcquisitionTeam = string.Join(", ", fileProperty.file.PimsAcquisitionFileTeams.Select(x => x.PersonId.HasValue ? x.Person.GetFullName(true) : x.Organization.Name)),
@@ -255,7 +255,7 @@ public PimsAcquisitionFile Update(PimsAcquisitionFile acquisitionFile, IEnumerab
if (!_statusSolver.CanEditDetails(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
if (!userOverrides.Contains(UserOverrideCode.UpdateRegion))
@@ -301,7 +301,7 @@ public PimsAcquisitionFile UpdateProperties(PimsAcquisitionFile acquisitionFile,
AcquisitionStatusTypes? currentAcquisitionStatus = GetCurrentAcquisitionStatus(acquisitionFile.Internal_Id);
if (!_statusSolver.CanEditProperties(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
// Get the current properties in the research file
@@ -368,7 +368,7 @@ public PimsAcquisitionFile UpdateChecklistItems(IList UpdateInterestHolders(long acquisitionFil
var currentAcquisitionStatus = GetCurrentAcquisitionStatus(acquisitionFileId);
if (!_statusSolver.CanEditStakeholders(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
var currentInterestHolders = _interestHolderRepository.GetInterestHoldersByAcquisitionFile(acquisitionFileId);
@@ -735,7 +735,7 @@ private void ValidateAcquisitionFileStatus(long acquisitionFileId, string agreem
if (!_statusSolver.CanEditOrDeleteAgreement(currentAcquisitionStatus, agreementStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
}
diff --git a/source/backend/api/Services/CompensationRequisitionService.cs b/source/backend/api/Services/CompensationRequisitionService.cs
index 08b170feec..8b4592540a 100644
--- a/source/backend/api/Services/CompensationRequisitionService.cs
+++ b/source/backend/api/Services/CompensationRequisitionService.cs
@@ -67,7 +67,7 @@ public PimsCompensationRequisition Update(PimsCompensationRequisition compensati
if (!_statusSolver.CanEditOrDeleteCompensation(currentAcquisitionStatus, currentCompensation.IsDraft) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
CheckTotalAllowableCompensation(currentAcquisitionFile, compensationRequisition);
@@ -106,7 +106,7 @@ public bool DeleteCompensation(long compensationId)
if (!_statusSolver.CanEditOrDeleteCompensation(currentAcquisitionStatus, currentCompensation.IsDraft) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
var fileFormToDelete = _compensationRequisitionRepository.TryDelete(compensationId);
diff --git a/source/backend/api/Services/DispositionFileService.cs b/source/backend/api/Services/DispositionFileService.cs
index d3e3721cd5..ae8dc4062c 100644
--- a/source/backend/api/Services/DispositionFileService.cs
+++ b/source/backend/api/Services/DispositionFileService.cs
@@ -71,8 +71,8 @@ public PimsDispositionFile Add(PimsDispositionFile dispositionFile, IEnumerable<
_user.ThrowIfNotAuthorized(Permissions.DispositionAdd);
dispositionFile.ThrowMissingContractorInTeam(_user, _userRepository);
- dispositionFile.DispositionStatusTypeCode ??= EnumDispositionStatusTypeCode.UNKNOWN.ToString();
- dispositionFile.DispositionFileStatusTypeCode ??= EnumDispositionFileStatusTypeCode.ACTIVE.ToString();
+ dispositionFile.DispositionStatusTypeCode ??= DispositionStatusTypes.UNKNOWN.ToString();
+ dispositionFile.DispositionFileStatusTypeCode ??= DispositionFileStatusTypes.ACTIVE.ToString();
ValidateStaff(dispositionFile);
MatchProperties(dispositionFile, userOverrides);
@@ -108,10 +108,10 @@ public PimsDispositionFile Update(long id, PimsDispositionFile dispositionFile,
throw new BadRequestException("Invalid dispositionFileId.");
}
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFile.Internal_Id);
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFile.Internal_Id);
if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
ValidateVersion(id, dispositionFile.ConcurrencyControlNumber);
@@ -120,8 +120,8 @@ public PimsDispositionFile Update(long id, PimsDispositionFile dispositionFile,
var currentDispositionFile = _dispositionFileRepository.GetById(id);
ValidateFileBeforeUpdate(dispositionFile, currentDispositionFile, userOverrides);
- var isFileClosing = currentDispositionFile.DispositionFileStatusTypeCode != EnumDispositionFileStatusTypeCode.COMPLETE.ToString() &&
- dispositionFile.DispositionFileStatusTypeCode == EnumDispositionFileStatusTypeCode.COMPLETE.ToString();
+ var isFileClosing = currentDispositionFile.DispositionFileStatusTypeCode != DispositionFileStatusTypes.COMPLETE.ToString() &&
+ dispositionFile.DispositionFileStatusTypeCode == DispositionFileStatusTypes.COMPLETE.ToString();
if (isFileClosing && currentDispositionFile.PimsDispositionFileProperties?.Count > 0)
{
@@ -218,10 +218,10 @@ public PimsDispositionOffer AddDispositionFileOffer(long dispositionFileId, Pims
throw new BadRequestException("Invalid dispositionFileId.");
}
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
- if (!_dispositionStatusSolver.CanEditOrDeleteValuesOffersSales(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
+ if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
ValidateDispositionOfferStatus(dispositionFileParent, dispositionOffer);
@@ -243,10 +243,10 @@ public PimsDispositionOffer UpdateDispositionFileOffer(long dispositionFileId, l
throw new BadRequestException("Invalid dispositionFileId.");
}
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
- if (!_dispositionStatusSolver.CanEditOrDeleteValuesOffersSales(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
+ if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
ValidateDispositionOfferStatus(dispositionFileParent, dispositionOffer);
@@ -263,10 +263,10 @@ public bool DeleteDispositionFileOffer(long dispositionFileId, long offerId)
_user.ThrowIfNotAuthorized(Permissions.DispositionEdit);
var dispositionFile = _dispositionFileRepository.GetById(dispositionFileId);
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFile.Internal_Id);
- if (!_dispositionStatusSolver.CanEditOrDeleteValuesOffersSales(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFile.Internal_Id);
+ if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
var deleteResult = _dispositionFileRepository.TryDeleteDispositionOffer(dispositionFileId, offerId);
@@ -288,10 +288,10 @@ public PimsDispositionSale UpdateDispositionFileSale(PimsDispositionSale disposi
_logger.LogInformation("Updating disposition file Sale with DispositionFileId: {id}", dispositionSale.DispositionSaleId);
_user.ThrowIfNotAuthorized(Permissions.DispositionEdit);
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionSale.DispositionFileId);
- if (!_dispositionStatusSolver.CanEditOrDeleteValuesOffersSales(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionSale.DispositionFileId);
+ if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
var updatedSale = _dispositionFileRepository.UpdateDispositionFileSale(dispositionSale);
@@ -306,10 +306,10 @@ public PimsDispositionSale AddDispositionFileSale(PimsDispositionSale dispositio
_logger.LogInformation("Adding disposition file Sale to Disposition File with Id: {id}", dispositionSale.DispositionFileId);
_user.ThrowIfNotAuthorized(Permissions.DispositionEdit);
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionSale.DispositionFileId);
- if (!_dispositionStatusSolver.CanEditOrDeleteValuesOffersSales(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionSale.DispositionFileId);
+ if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
var dispositionFileParent = _dispositionFileRepository.GetById(dispositionSale.DispositionFileId);
@@ -348,10 +348,10 @@ public PimsDispositionAppraisal AddDispositionFileAppraisal(long dispositionFile
throw new DuplicateEntityException("Invalid Disposition Appraisal. An Appraisal has been already created for this Disposition File");
}
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
- if (!_dispositionStatusSolver.CanEditOrDeleteValuesOffersSales(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
+ if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
var newAppraisal = _dispositionFileRepository.AddDispositionFileAppraisal(dispositionAppraisal);
@@ -371,10 +371,10 @@ public PimsDispositionAppraisal UpdateDispositionFileAppraisal(long dispositionF
throw new BadRequestException("Invalid dispositionFileId.");
}
- DispositionStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
- if (!_dispositionStatusSolver.CanEditOrDeleteValuesOffersSales(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ DispositionFileStatusTypes? currentDispositionStatus = GetCurrentDispositionStatus(dispositionFileParent.Internal_Id);
+ if (!_dispositionStatusSolver.CanEditDetails(currentDispositionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
- throw new BusinessRuleViolationException("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ throw new BusinessRuleViolationException("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
var updatedAppraisal = _dispositionFileRepository.UpdateDispositionFileAppraisal(appraisalId, dispositionAppraisal);
@@ -534,12 +534,48 @@ public PimsDispositionFile UpdateProperties(PimsDispositionFile dispositionFile,
return _dispositionFileRepository.GetById(dispositionFile.Internal_Id);
}
+ private static decimal CalculateNetProceedsBeforeSpp(PimsDispositionSale sale)
+ {
+ if (sale != null)
+ {
+ return (sale?.SaleFinalAmt ?? 0) - ((sale?.RealtorCommissionAmt ?? 0) + (sale.GstCollectedAmt ?? 0) + (sale.NetBookAmt ?? 0) + (sale.TotalCostAmt ?? 0));
+ }
+ return 0;
+ }
+
+ private static decimal CalculateNetProceedsAfterSpp(PimsDispositionSale sale)
+ {
+ if (sale != null)
+ {
+ return (sale?.SaleFinalAmt ?? 0) - ((sale?.RealtorCommissionAmt ?? 0) + (sale.GstCollectedAmt ?? 0) + (sale.NetBookAmt ?? 0) + (sale.TotalCostAmt ?? 0) + (sale.SppAmt ?? 0));
+ }
+ return 0;
+ }
+
+ private static void ValidateStaff(PimsDispositionFile dispositionFile)
+ {
+ bool duplicate = dispositionFile.PimsDispositionFileTeams.GroupBy(p => p.DspFlTeamProfileTypeCode).Any(g => g.Count() > 1);
+ if (duplicate)
+ {
+ throw new BadRequestException("Invalid Disposition team, each team member and role combination can only be added once.");
+ }
+ }
+
+ private static void ValidateDispositionOfferStatus(PimsDispositionFile dispositionFile, PimsDispositionOffer newOffer)
+ {
+ bool offerAlreadyAccepted = dispositionFile.PimsDispositionOffers.Any(x => x.DispositionOfferStatusTypeCode == EnumDispositionOfferStatusTypeCode.ACCCEPTED.ToString() && x.DispositionOfferId != newOffer.DispositionOfferId);
+ if (offerAlreadyAccepted && !string.IsNullOrEmpty(newOffer.DispositionOfferStatusTypeCode) && newOffer.DispositionOfferStatusTypeCode == EnumDispositionOfferStatusTypeCode.ACCCEPTED.ToString())
+ {
+ throw new DuplicateEntityException("Invalid Disposition Offer, an Offer has been already accepted for this Disposition File");
+ }
+ }
+
private void ValidateFileBeforeUpdate(PimsDispositionFile incomingDispositionFile, PimsDispositionFile currentDispositionFile, IEnumerable userOverrides)
{
// Implement file validation logic before proceeding to update. This includes file closing validation.
// The order of validation checks is important as it has been requested by business users.
- var isFileClosing = currentDispositionFile.DispositionFileStatusTypeCode != EnumDispositionFileStatusTypeCode.COMPLETE.ToString() &&
- incomingDispositionFile.DispositionFileStatusTypeCode == EnumDispositionFileStatusTypeCode.COMPLETE.ToString();
+ var isFileClosing = currentDispositionFile.DispositionFileStatusTypeCode != DispositionFileStatusTypes.COMPLETE.ToString() &&
+ incomingDispositionFile.DispositionFileStatusTypeCode == DispositionFileStatusTypes.COMPLETE.ToString();
var currentProperties = _dispositionFilePropertyRepository.GetPropertiesByDispositionFileId(incomingDispositionFile.Internal_Id);
@@ -567,10 +603,10 @@ private void ValidateFileBeforeUpdate(PimsDispositionFile incomingDispositionFil
ValidateMinistryRegion(incomingDispositionFile.Internal_Id, incomingDispositionFile.RegionCode);
}
- var nonEditableStatuses = new List() { EnumDispositionFileStatusTypeCode.COMPLETE.ToString(), EnumDispositionFileStatusTypeCode.ARCHIVED.ToString(), EnumDispositionFileStatusTypeCode.CANCELLED.ToString(), };
+ var nonEditableStatuses = new List() { DispositionFileStatusTypes.COMPLETE.ToString(), DispositionFileStatusTypes.ARCHIVED.ToString(), DispositionFileStatusTypes.CANCELLED.ToString(), };
var isFileChangingToNonEditableState = !nonEditableStatuses.Contains(currentDispositionFile.DispositionFileStatusTypeCode) && nonEditableStatuses.Contains(incomingDispositionFile.DispositionFileStatusTypeCode);
- if (isFileClosing && incomingDispositionFile.DispositionStatusTypeCode != EnumDispositionStatusTypeCode.SOLD.ToString())
+ if (isFileClosing && incomingDispositionFile.DispositionStatusTypeCode != DispositionStatusTypes.SOLD.ToString())
{
throw new BusinessRuleViolationException("File Disposition Status has not been set to SOLD, so the related file properties cannot be Disposed. To proceed, set file disposition status to SOLD, or cancel the Disposition file.");
}
@@ -605,42 +641,6 @@ private void DisposeOfProperties(PimsDispositionFile dispositionFile)
}
}
- private static decimal CalculateNetProceedsBeforeSpp(PimsDispositionSale sale)
- {
- if (sale != null)
- {
- return (sale?.SaleFinalAmt ?? 0) - ((sale?.RealtorCommissionAmt ?? 0) + (sale.GstCollectedAmt ?? 0) + (sale.NetBookAmt ?? 0) + (sale.TotalCostAmt ?? 0));
- }
- return 0;
- }
-
- private static decimal CalculateNetProceedsAfterSpp(PimsDispositionSale sale)
- {
- if (sale != null)
- {
- return (sale?.SaleFinalAmt ?? 0) - ((sale?.RealtorCommissionAmt ?? 0) + (sale.GstCollectedAmt ?? 0) + (sale.NetBookAmt ?? 0) + (sale.TotalCostAmt ?? 0) + (sale.SppAmt ?? 0));
- }
- return 0;
- }
-
- private static void ValidateStaff(PimsDispositionFile dispositionFile)
- {
- bool duplicate = dispositionFile.PimsDispositionFileTeams.GroupBy(p => p.DspFlTeamProfileTypeCode).Any(g => g.Count() > 1);
- if (duplicate)
- {
- throw new BadRequestException("Invalid Disposition team, each team member and role combination can only be added once.");
- }
- }
-
- private static void ValidateDispositionOfferStatus(PimsDispositionFile dispositionFile, PimsDispositionOffer newOffer)
- {
- bool offerAlreadyAccepted = dispositionFile.PimsDispositionOffers.Any(x => x.DispositionOfferStatusTypeCode == EnumDispositionOfferStatusTypeCode.ACCCEPTED.ToString() && x.DispositionOfferId != newOffer.DispositionOfferId);
- if (offerAlreadyAccepted && !string.IsNullOrEmpty(newOffer.DispositionOfferStatusTypeCode) && newOffer.DispositionOfferStatusTypeCode == EnumDispositionOfferStatusTypeCode.ACCCEPTED.ToString())
- {
- throw new DuplicateEntityException("Invalid Disposition Offer, an Offer has been already accepted for this Disposition File");
- }
- }
-
private void AddNoteIfStatusChanged(PimsDispositionFile updateDispositionFile)
{
var currentDispositionFile = _dispositionFileRepository.GetById(updateDispositionFile.Internal_Id);
@@ -815,17 +815,17 @@ private void ValidateVersion(long dispositionFileId, long dispositionFileVersion
}
}
- private DispositionStatusTypes? GetCurrentDispositionStatus(long dispositionFileId)
+ private DispositionFileStatusTypes? GetCurrentDispositionStatus(long dispositionFileId)
{
var currentDispositionFile = _dispositionFileRepository.GetById(dispositionFileId);
- DispositionStatusTypes currentDispositionStatus;
+ DispositionFileStatusTypes currentDispositionFileStatus;
- if (Enum.TryParse(currentDispositionFile.DispositionFileStatusTypeCode, out currentDispositionStatus))
+ if (Enum.TryParse(currentDispositionFile.DispositionFileStatusTypeCode, out currentDispositionFileStatus))
{
- return currentDispositionStatus;
+ return currentDispositionFileStatus;
}
- return currentDispositionStatus;
+ return currentDispositionFileStatus;
}
}
}
diff --git a/source/backend/api/Services/ITakeService.cs b/source/backend/api/Services/ITakeService.cs
index 5758235c33..6548486492 100644
--- a/source/backend/api/Services/ITakeService.cs
+++ b/source/backend/api/Services/ITakeService.cs
@@ -1,16 +1,24 @@
using System.Collections.Generic;
using Pims.Dal.Entities;
+using Pims.Dal.Exceptions;
namespace Pims.Api.Services
{
public interface ITakeService
{
+
+ PimsTake GetById(long takeId);
+
+ PimsTake AddAcquisitionPropertyTake(long acquisitionFilePropertyId, PimsTake take);
+
+ PimsTake UpdateAcquisitionPropertyTake(long acquisitionFilePropertyId, PimsTake take);
+
+ bool DeleteAcquisitionPropertyTake(long takeId, IEnumerable userOverrides);
+
IEnumerable GetByFileId(long fileId);
IEnumerable GetByPropertyId(long fileId, long acquisitionFilePropertyId);
int GetCountByPropertyId(long propertyId);
-
- IEnumerable UpdateAcquisitionPropertyTakes(long acquisitionFilePropertyId, IEnumerable takes);
}
}
diff --git a/source/backend/api/Services/TakeService.cs b/source/backend/api/Services/TakeService.cs
index fb5698f7b1..cad1988544 100644
--- a/source/backend/api/Services/TakeService.cs
+++ b/source/backend/api/Services/TakeService.cs
@@ -7,6 +7,7 @@
using Pims.Api.Models.CodeTypes;
using Pims.Core.Exceptions;
using Pims.Dal.Entities;
+using Pims.Dal.Exceptions;
using Pims.Dal.Helpers.Extensions;
using Pims.Dal.Repositories;
using Pims.Dal.Security;
@@ -43,6 +44,13 @@ public TakeService(
_propertyRepository = propertyRepository;
}
+ public PimsTake GetById(long takeId)
+ {
+ _logger.LogInformation("Getting take with takeId {takeId}", takeId);
+ _user.ThrowIfNotAuthorized(Permissions.PropertyView, Permissions.AcquisitionFileView);
+ return _takeRepository.GetById(takeId);
+ }
+
public IEnumerable GetByFileId(long fileId)
{
_logger.LogInformation("Getting takes with fileId {fileId}", fileId);
@@ -64,65 +72,176 @@ public int GetCountByPropertyId(long propertyId)
return _takeRepository.GetCountByPropertyId(propertyId);
}
- public IEnumerable UpdateAcquisitionPropertyTakes(long acquisitionFilePropertyId, IEnumerable takes)
+ public PimsTake AddAcquisitionPropertyTake(long acquisitionFilePropertyId, PimsTake take)
{
- _logger.LogInformation("updating takes with propertyFileId {propertyFileId}", acquisitionFilePropertyId);
+ _logger.LogInformation("adding take with propertyFileId {propertyFileId}", acquisitionFilePropertyId);
_user.ThrowIfNotAuthorized(Permissions.PropertyView, Permissions.AcquisitionFileView);
- var currentAcquistionFile = _acqFileRepository.GetByAcquisitionFilePropertyId(acquisitionFilePropertyId);
+ ValidateTakeRules(acquisitionFilePropertyId, take);
+
+ // Add take
+ var addedTake = _takeRepository.AddTake(take);
+
+ RecalculateOwnership(acquisitionFilePropertyId, take);
+
+ _takeRepository.CommitTransaction();
+ return addedTake;
+ }
+
+ public PimsTake UpdateAcquisitionPropertyTake(long acquisitionFilePropertyId, PimsTake take)
+ {
+ _logger.LogInformation("updating take with propertyFileId {propertyFileId}", acquisitionFilePropertyId);
+ _user.ThrowIfNotAuthorized(Permissions.PropertyView, Permissions.AcquisitionFileView);
+
+ ValidateTakeRules(acquisitionFilePropertyId, take);
+
+ // Update take
+ var updatedTake = _takeRepository.UpdateTake(take);
+
+ RecalculateOwnership(acquisitionFilePropertyId, take);
+
+ _takeRepository.CommitTransaction();
+ return updatedTake;
+ }
+
+ public bool DeleteAcquisitionPropertyTake(long takeId, IEnumerable userOverrides)
+ {
+ _logger.LogInformation("deleting take with {takeId}", takeId);
+ _user.ThrowIfNotAuthorized(Permissions.PropertyView, Permissions.AcquisitionFileView);
+
+ var takeToDelete = _takeRepository.GetById(takeId);
+ var propertyWithAssociations = _propertyRepository.GetAllAssociationsById(takeToDelete.PropertyAcquisitionFile.PropertyId);
+ var currentAcquisitionFile = _acqFileRepository.GetByAcquisitionFilePropertyId(takeToDelete.PropertyAcquisitionFileId);
+ var allTakesForProperty = _takeRepository.GetAllByPropertyId(takeToDelete.PropertyAcquisitionFile.PropertyId);
+ if ((!_statusSolver.CanEditTakes(Enum.Parse(currentAcquisitionFile.AcquisitionFileStatusTypeCode)) || takeToDelete.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString())
+ && !_user.HasPermission(Permissions.SystemAdmin))
+ {
+ throw new BusinessRuleViolationException("Retired records are referenced for historical purposes only and cannot be edited or deleted. If the take has been added in error, contact your system administrator to re-open the file, which will allow take deletion.");
+ }
+ else if(propertyWithAssociations?.PimsDispositionFileProperties?.Any(d => d.DispositionFile.DispositionFileStatusTypeCode == DispositionFileStatusTypes.COMPLETE.ToString()) == true)
+ {
+ throw new BusinessRuleViolationException("You cannot delete a take that has a completed disposition attached to the same property.");
+ }
+ else if (propertyWithAssociations?.IsRetired == true)
+ {
+ throw new BusinessRuleViolationException("You cannot delete a take from a retired property.");
+ }
+
+ // user overrides
+ if (takeToDelete.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString() && _user.HasPermission(Permissions.SystemAdmin))
+ {
+ if (propertyWithAssociations?.PimsDispositionFileProperties?.Any(d => d.DispositionFile.DispositionFileStatusTypeCode == DispositionFileStatusTypes.ACTIVE.ToString()) == true && !userOverrides.Contains(UserOverrideCode.DeleteTakeActiveDisposition))
+ {
+ throw new UserOverrideException(UserOverrideCode.DeleteTakeActiveDisposition, "You are deleting a take. Property ownership state will be recalculated based upon any remaining completed takes. It should be noted that one or more related dispositions are in progress that should also be reviewed. \n\nDo you want to acknowledge and proceed?");
+ }
+ else if (allTakesForProperty.Count(t => !IsTakeExpired(t) && t.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString()) == 1 && allTakesForProperty.FirstOrDefault().TakeId == takeId && !userOverrides.Contains(UserOverrideCode.DeleteLastTake))
+ {
+ throw new UserOverrideException(UserOverrideCode.DeleteLastTake, "You are deleting the last non-expired completed take on this property. This property will become a property of interest.\n\nDo you want to acknowledge and proceed?");
+ }
+ else if (!userOverrides.Contains(UserOverrideCode.DeleteCompletedTake) && !userOverrides.Contains(UserOverrideCode.DeleteLastTake) && !userOverrides.Contains(UserOverrideCode.DeleteTakeActiveDisposition))
+ {
+ throw new UserOverrideException(UserOverrideCode.DeleteCompletedTake, "You are deleting a completed take. Property ownership state will be recalculated based upon any remaining completed takes.\n\nDo you want to acknowledge and proceed?");
+ }
+ }
+
+ var wasTakeDeleted = _takeRepository.TryDeleteTake(takeId);
+
+ if (wasTakeDeleted)
+ {
+ // Evaluate if the property needs to be updated
+ var currentProperty = _acqFileRepository.GetProperty(takeToDelete.PropertyAcquisitionFileId);
+ var currentTakes = _takeRepository.GetAllByPropertyId(currentProperty.PropertyId);
+
+ var completedTakes = currentTakes
+ .Where(x => x.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString() && x.TakeId != takeId).ToList();
+
+ if (completedTakes.Count > 0 || takeToDelete.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString())
+ {
+ if (_takeInteractionSolver.ResultsInOwnedProperty(completedTakes))
+ {
+ _propertyRepository.TransferFileProperty(currentProperty, true);
+ }
+ else
+ {
+ _propertyRepository.TransferFileProperty(currentProperty, false);
+ }
+ }
+ }
+
+ _takeRepository.CommitTransaction();
+ return wasTakeDeleted;
+ }
+
+ private static bool IsTakeExpired(PimsTake take)
+ {
+ return (take.IsActiveLease && take.ActiveLeaseEndDt > DateOnly.FromDateTime(DateTime.Now))
+ || (take.IsNewLandAct && take.LandActEndDt > DateOnly.FromDateTime(DateTime.Now))
+ || (take.IsNewLicenseToConstruct && take.LtcEndDt > DateOnly.FromDateTime(DateTime.Now))
+ || (take.IsNewInterestInSrw && take.SrwEndDt > DateOnly.FromDateTime(DateTime.Now));
+ }
+
+ private void ValidateTakeRules(long acquisitionFilePropertyId, PimsTake take)
+ {
var currentFilePropertyTakes = _takeRepository.GetAllByPropertyAcquisitionFileId(acquisitionFilePropertyId);
+ var currentAcquistionFile = _acqFileRepository.GetByAcquisitionFilePropertyId(acquisitionFilePropertyId);
var currentAcquisitionStatus = Enum.Parse(currentAcquistionFile.AcquisitionFileStatusTypeCode);
if (!_statusSolver.CanEditTakes(currentAcquisitionStatus) && !_user.HasPermission(Permissions.SystemAdmin))
{
throw new BusinessRuleViolationException("Retired records are referenced for historical purposes only and cannot be edited or deleted. If the take has been added in error, contact your system administrator to re-open the file, which will allow take deletion.");
}
- else if (takes.Any(t => t.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString() && t.CompletionDt == null))
+ else if (take.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString() && take.CompletionDt == null)
{
throw new BusinessRuleViolationException("A completed take must have a completion date.");
}
- else if (takes.Any(t => t.IsNewLandAct && t.LandActEndDt != null && (t.LandActTypeCode == LandActTypes.CROWN_GRANT.ToString() || t.LandActTypeCode == LandActTypes.TRANSFER_OF_ADMIN_AND_CONTROL.ToString())))
+ else if (take.IsNewLandAct && take.LandActEndDt != null && (take.LandActTypeCode == LandActTypes.CROWN_GRANT.ToString() || take.LandActTypeCode == LandActTypes.TRANSFER_OF_ADMIN_AND_CONTROL.ToString()))
{
throw new BusinessRuleViolationException("'Crown Grant' and 'Transfer' Land Acts cannot have an end date.");
}
else
{
- // Complete Takes can only be deleted or set to InProgress by Admins when File is Active/Draft
+ // Complete Takes can only be set to InProgress by Admins when File is Active/Draft
var currentCompleteTakes = currentFilePropertyTakes
.Where(x => x.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString()).ToList();
if (currentCompleteTakes.Count > 0)
{
- foreach (var completeTake in currentCompleteTakes)
+ var updatedTake = currentCompleteTakes.FirstOrDefault(x => x.TakeId == take.TakeId);
+ if (!_user.HasPermission(Permissions.SystemAdmin) && (updatedTake is not null && updatedTake.TakeStatusTypeCode != take.TakeStatusTypeCode))
{
- // Validate that the current completed take can only by updated by a sysadmin
- var updatedTake = takes.FirstOrDefault(x => x.TakeId == completeTake.TakeId);
- if (!_user.HasPermission(Permissions.SystemAdmin) && (updatedTake is null || (updatedTake is not null && updatedTake.TakeStatusTypeCode != completeTake.TakeStatusTypeCode)))
- {
- throw new BusinessRuleViolationException("Retired records are referenced for historical purposes only and cannot be edited or deleted. If the take has been added in error, contact your system administrator to re-open the file, which will allow take deletion.");
- }
+ throw new BusinessRuleViolationException("Retired records are referenced for historical purposes only and cannot be edited or deleted. If the take has been added in error, contact your system administrator to re-open the file, which will allow take deletion.");
}
}
}
+ }
- // Update takes
- _takeRepository.UpdateAcquisitionPropertyTakes(acquisitionFilePropertyId, takes);
-
+ private void RecalculateOwnership(long acquisitionFilePropertyId, PimsTake take)
+ {
// Evaluate if the property needs to be updated
var currentProperty = _acqFileRepository.GetProperty(acquisitionFilePropertyId);
var currentTakes = _takeRepository.GetAllByPropertyId(currentProperty.PropertyId);
- var completedTakes = currentTakes.Union(takes)
+ var allTakes = currentTakes;
+ if (take != null)
+ {
+ allTakes = allTakes.Append(take);
+ }
+
+ var completedTakes = allTakes
.Where(x => x.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString()).ToList();
- if (_takeInteractionSolver.ResultsInOwnedProperty(completedTakes))
+ if (completedTakes.Count > 0)
{
- _propertyRepository.TransferFileProperty(currentProperty, true);
+ if (_takeInteractionSolver.ResultsInOwnedProperty(completedTakes))
+ {
+ _propertyRepository.TransferFileProperty(currentProperty, true);
+ }
+ else
+ {
+ _propertyRepository.TransferFileProperty(currentProperty, false);
+ }
}
-
- _takeRepository.CommitTransaction();
- return _takeRepository.GetAllByPropertyAcquisitionFileId(acquisitionFilePropertyId);
}
}
}
diff --git a/source/backend/api/Solvers/DispositionStatusSolver.cs b/source/backend/api/Solvers/DispositionStatusSolver.cs
index a77f9c0ffc..a834e5f880 100644
--- a/source/backend/api/Solvers/DispositionStatusSolver.cs
+++ b/source/backend/api/Solvers/DispositionStatusSolver.cs
@@ -1,69 +1,10 @@
-using Pims.Api.Constants;
+using Pims.Api.Models.CodeTypes;
namespace Pims.Api.Services
{
public class DispositionStatusSolver : IDispositionStatusSolver
{
-
- public bool CanEditDetails(DispositionStatusTypes? dispositionStatus)
- {
- if (dispositionStatus == null)
- {
- return false;
- }
-
- bool canEdit;
- switch (dispositionStatus)
- {
- case DispositionStatusTypes.ACTIVE:
- case DispositionStatusTypes.DRAFT:
- canEdit = true;
- break;
- case DispositionStatusTypes.ARCHIVED:
- case DispositionStatusTypes.CANCELLED:
- case DispositionStatusTypes.CLOSED:
- case DispositionStatusTypes.COMPLETE:
- case DispositionStatusTypes.HOLD:
- canEdit = false;
- break;
- default:
- canEdit = false;
- break;
- }
-
- return canEdit;
- }
-
- public bool CanEditProperties(DispositionStatusTypes? dispositionStatus)
- {
- if (dispositionStatus == null)
- {
- return false;
- }
-
- bool canEdit;
- switch (dispositionStatus)
- {
- case DispositionStatusTypes.ACTIVE:
- case DispositionStatusTypes.DRAFT:
- canEdit = true;
- break;
- case DispositionStatusTypes.ARCHIVED:
- case DispositionStatusTypes.CANCELLED:
- case DispositionStatusTypes.CLOSED:
- case DispositionStatusTypes.COMPLETE:
- case DispositionStatusTypes.HOLD:
- canEdit = false;
- break;
- default:
- canEdit = false;
- break;
- }
-
- return canEdit;
- }
-
- public bool CanEditOrDeleteValuesOffersSales(DispositionStatusTypes? dispositionStatus)
+ public bool CanEditDetails(DispositionFileStatusTypes? dispositionStatus)
{
if (dispositionStatus == null)
{
@@ -73,15 +14,14 @@ public bool CanEditOrDeleteValuesOffersSales(DispositionStatusTypes? disposition
bool canEdit;
switch (dispositionStatus)
{
- case DispositionStatusTypes.ACTIVE:
- case DispositionStatusTypes.DRAFT:
+ case DispositionFileStatusTypes.ACTIVE:
+ case DispositionFileStatusTypes.DRAFT:
+ case DispositionFileStatusTypes.HOLD:
canEdit = true;
break;
- case DispositionStatusTypes.ARCHIVED:
- case DispositionStatusTypes.CANCELLED:
- case DispositionStatusTypes.CLOSED:
- case DispositionStatusTypes.COMPLETE:
- case DispositionStatusTypes.HOLD:
+ case DispositionFileStatusTypes.ARCHIVED:
+ case DispositionFileStatusTypes.CANCELLED:
+ case DispositionFileStatusTypes.COMPLETE:
canEdit = false;
break;
default:
diff --git a/source/backend/api/Solvers/IDispositionStatusSolver.cs b/source/backend/api/Solvers/IDispositionStatusSolver.cs
index fb977e9b3e..b8fbebfbd9 100644
--- a/source/backend/api/Solvers/IDispositionStatusSolver.cs
+++ b/source/backend/api/Solvers/IDispositionStatusSolver.cs
@@ -1,13 +1,9 @@
-using Pims.Api.Constants;
+using Pims.Api.Models.CodeTypes;
namespace Pims.Api.Services
{
public interface IDispositionStatusSolver
{
- bool CanEditDetails(DispositionStatusTypes? dispositionStatus);
-
- bool CanEditProperties(DispositionStatusTypes? dispositionStatus);
-
- bool CanEditOrDeleteValuesOffersSales(DispositionStatusTypes? dispositionStatus);
+ bool CanEditDetails(DispositionFileStatusTypes? dispositionStatus);
}
}
diff --git a/source/backend/api/Constants/DispositionStatusTypes.cs b/source/backend/apimodels/CodeTypes/DispositionFileStatusTypes.cs
similarity index 79%
rename from source/backend/api/Constants/DispositionStatusTypes.cs
rename to source/backend/apimodels/CodeTypes/DispositionFileStatusTypes.cs
index 46c97dcf88..2727652a67 100644
--- a/source/backend/api/Constants/DispositionStatusTypes.cs
+++ b/source/backend/apimodels/CodeTypes/DispositionFileStatusTypes.cs
@@ -1,10 +1,10 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
-namespace Pims.Api.Constants
+namespace Pims.Api.Models.CodeTypes
{
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
- public enum DispositionStatusTypes
+ public enum DispositionFileStatusTypes
{
[EnumMember(Value = "ACTIVE")]
ACTIVE,
@@ -15,9 +15,6 @@ public enum DispositionStatusTypes
[EnumMember(Value = "CANCELLED")]
CANCELLED,
- [EnumMember(Value = "CLOSED")]
- CLOSED,
-
[EnumMember(Value = "COMPLETE")]
COMPLETE,
diff --git a/source/backend/api/Constants/EnumDispositionStatusTypeCode.cs b/source/backend/apimodels/CodeTypes/DispositionStatusTypes.cs
similarity index 69%
rename from source/backend/api/Constants/EnumDispositionStatusTypeCode.cs
rename to source/backend/apimodels/CodeTypes/DispositionStatusTypes.cs
index 7345b518da..b587cf58fb 100644
--- a/source/backend/api/Constants/EnumDispositionStatusTypeCode.cs
+++ b/source/backend/apimodels/CodeTypes/DispositionStatusTypes.cs
@@ -1,8 +1,11 @@
using System.Runtime.Serialization;
+using System.Text.Json.Serialization;
-namespace Pims.Api.Constants
+namespace Pims.Api.Models.CodeTypes
{
- public enum EnumDispositionStatusTypeCode
+ [JsonConverter(typeof(JsonStringEnumMemberConverter))]
+
+ public enum DispositionStatusTypes
{
[EnumMember(Value = "LISTED")]
LISTED,
diff --git a/source/backend/apimodels/CodeTypes/TakeTypes.cs b/source/backend/apimodels/CodeTypes/TakeTypes.cs
new file mode 100644
index 0000000000..843e528b32
--- /dev/null
+++ b/source/backend/apimodels/CodeTypes/TakeTypes.cs
@@ -0,0 +1,15 @@
+using System.Runtime.Serialization;
+using System.Text.Json.Serialization;
+
+namespace Pims.Api.Models.CodeTypes
+{
+ [JsonConverter(typeof(JsonStringEnumMemberConverter))]
+ public enum TakeTypes
+ {
+ [EnumMember(Value = "TOTAL")]
+ TOTAL,
+
+ [EnumMember(Value = "PARTIAL")]
+ PARTIAL,
+ }
+}
diff --git a/source/backend/dal/Exceptions/OverrideExceptions.cs b/source/backend/dal/Exceptions/OverrideExceptions.cs
index cfd4fa58b7..df35cd7bec 100644
--- a/source/backend/dal/Exceptions/OverrideExceptions.cs
+++ b/source/backend/dal/Exceptions/OverrideExceptions.cs
@@ -50,6 +50,21 @@ public static UserOverrideCode DisposeOfProperties
get { return new UserOverrideCode("DISPOSE_OF_PROPERTIES"); }
}
+ public static UserOverrideCode DeleteCompletedTake
+ {
+ get { return new UserOverrideCode("DELETE_COMPLETED_TAKE"); }
+ }
+
+ public static UserOverrideCode DeleteLastTake
+ {
+ get { return new UserOverrideCode("DELETE_LAST_TAKE"); }
+ }
+
+ public static UserOverrideCode DeleteTakeActiveDisposition
+ {
+ get { return new UserOverrideCode("DELETE_TAKE_ACTIVE_DISPOSITION"); }
+ }
+
public string Code { get; private set; }
private static List UserOverrideCodes => new List()
@@ -63,6 +78,9 @@ public static UserOverrideCode DisposeOfProperties
UserOverrideCode.DisposingPropertyNotInventoried,
UserOverrideCode.DispositionFileFinalStatus,
UserOverrideCode.DisposeOfProperties,
+ UserOverrideCode.DeleteCompletedTake,
+ UserOverrideCode.DeleteLastTake,
+ UserOverrideCode.DeleteTakeActiveDisposition,
};
private UserOverrideCode(string code)
diff --git a/source/backend/dal/Repositories/Interfaces/ITakeRepository.cs b/source/backend/dal/Repositories/Interfaces/ITakeRepository.cs
index c76900118c..69bb5c2169 100644
--- a/source/backend/dal/Repositories/Interfaces/ITakeRepository.cs
+++ b/source/backend/dal/Repositories/Interfaces/ITakeRepository.cs
@@ -10,13 +10,19 @@ public interface ITakeRepository : IRepository
{
IEnumerable GetAllByAcquisitionFileId(long fileId);
- IEnumerable GetAllByAcqPropertyId(long fileId, long acquisitionFilePropertyId);
+ IEnumerable GetAllByAcqPropertyId(long fileId, long propertyId);
IEnumerable GetAllByPropertyId(long propertyId);
- int GetCountByPropertyId(long propertyId);
+ PimsTake GetById(long takeId);
+
+ PimsTake AddTake(PimsTake take);
+
+ PimsTake UpdateTake(PimsTake take);
- void UpdateAcquisitionPropertyTakes(long acquisitionFilePropertyId, IEnumerable takes);
+ bool TryDeleteTake(long takeId);
+
+ int GetCountByPropertyId(long propertyId);
IEnumerable GetAllByPropertyAcquisitionFileId(long acquisitionFilePropertyId);
}
diff --git a/source/backend/dal/Repositories/TakeRepository.cs b/source/backend/dal/Repositories/TakeRepository.cs
index c82fe18a04..a9043a53a7 100644
--- a/source/backend/dal/Repositories/TakeRepository.cs
+++ b/source/backend/dal/Repositories/TakeRepository.cs
@@ -24,6 +24,24 @@ public TakeRepository(PimsContext dbContext, ClaimsPrincipal user, ILogger
+ /// Get take by id.
+ ///
+ ///
+ ///
+ public PimsTake GetById(long takeId)
+ {
+ return Context.PimsTakes
+
+ .Include(t => t.PropertyAcquisitionFile)
+ .Include(t => t.TakeSiteContamTypeCodeNavigation)
+ .Include(t => t.TakeStatusTypeCodeNavigation)
+ .Include(t => t.TakeTypeCodeNavigation)
+ .Include(t => t.LandActTypeCodeNavigation)
+ .AsNoTracking()
+ .FirstOrDefault(t => t.TakeId == takeId) ?? throw new KeyNotFoundException($"Unable to find take with id {takeId}");
+ }
+
///
/// Get all of the takes that are associated to a given acquisition file by its id.
///
@@ -46,9 +64,9 @@ public IEnumerable GetAllByAcquisitionFileId(long fileId)
/// Get all Takes for a Property in the Acquisition File.
///
///
- ///
+ ///
///
- public IEnumerable GetAllByAcqPropertyId(long fileId, long acquisitionFilePropertyId)
+ public IEnumerable GetAllByAcqPropertyId(long fileId, long propertyId)
{
return Context.PimsTakes
.Include(t => t.PropertyAcquisitionFile)
@@ -57,7 +75,7 @@ public IEnumerable GetAllByAcqPropertyId(long fileId, long acquisition
.Include(t => t.TakeTypeCodeNavigation)
.Include(t => t.LandActTypeCodeNavigation)
.Where(t => t.PropertyAcquisitionFile.AcquisitionFileId == fileId
- && t.PropertyAcquisitionFile.PropertyId == acquisitionFilePropertyId)
+ && t.PropertyAcquisitionFile.PropertyId == propertyId)
.AsNoTracking();
}
@@ -87,14 +105,44 @@ public int GetCountByPropertyId(long propertyId)
.Count();
}
+ public PimsTake AddTake(PimsTake take)
+ {
+ using var scope = Logger.QueryScope();
+
+ Context.PimsTakes.Add(take);
+
+ return take;
+ }
+
///
- /// Sets the passed list of takes as the takes associated to the given acquisition property, adding, deleting and updating as necessary.
+ /// Update the passed take.
///
- ///
- ///
- public void UpdateAcquisitionPropertyTakes(long acquisitionFilePropertyId, IEnumerable takes)
+ ///
+ public PimsTake UpdateTake(PimsTake take)
+ {
+ using var scope = Logger.QueryScope();
+
+ var existingTake = Context.PimsTakes.FirstOrDefault(x => x.TakeId == take.TakeId) ?? throw new KeyNotFoundException();
+
+ take.PropertyAcquisitionFileId = existingTake.PropertyAcquisitionFileId; // A take cannot be migrated between properties.
+ Context.Entry(existingTake).CurrentValues.SetValues(take);
+
+ return existingTake;
+ }
+
+ public bool TryDeleteTake(long takeId)
{
- Context.UpdateChild(p => p.PimsTakes, acquisitionFilePropertyId, takes.ToArray(), true);
+ using var scope = Logger.QueryScope();
+
+ var deletedEntity = Context.PimsTakes.Where(x => x.TakeId == takeId).FirstOrDefault();
+ if (deletedEntity is not null)
+ {
+ Context.PimsTakes.Remove(deletedEntity);
+
+ return true;
+ }
+
+ return false;
}
public IEnumerable GetAllByPropertyAcquisitionFileId(long acquisitionFilePropertyId)
diff --git a/source/backend/entities/Extensions/ExpiringTypeEntity.cs b/source/backend/entities/Extensions/ExpiringTypeEntity.cs
index 12109900ca..38ff5e763f 100644
--- a/source/backend/entities/Extensions/ExpiringTypeEntity.cs
+++ b/source/backend/entities/Extensions/ExpiringTypeEntity.cs
@@ -24,7 +24,7 @@ public static bool IsExpiredType(this IExpiringTypeEntity t
/// True if the type is expired; false otherwise.
public static bool IsExpiredType(this IExpiringTypeEntity type, DateTime? currentDate = null)
{
- DateOnly now = DateOnly.FromDateTime(currentDate.HasValue ? (DateTime)currentDate?.Date : DateTime.UtcNow.Date);
+ DateOnly now = DateOnly.FromDateTime(currentDate.HasValue ? (DateTime)currentDate?.Date : DateTime.Now.Date);
return (type.EffectiveDate > now) || (type.ExpiryDate.HasValue && type.ExpiryDate <= now);
}
}
diff --git a/source/backend/entities/PimsBaseContext.cs b/source/backend/entities/PimsBaseContext.cs
index 2d643e3d87..e5185e0e7a 100644
--- a/source/backend/entities/PimsBaseContext.cs
+++ b/source/backend/entities/PimsBaseContext.cs
@@ -222,6 +222,12 @@ public PimsBaseContext(DbContextOptions options)
public virtual DbSet PimsFenceTypes { get; set; }
+ public virtual DbSet PimsFileNumbers { get; set; }
+
+ public virtual DbSet PimsFileNumberHists { get; set; }
+
+ public virtual DbSet PimsFileNumberTypes { get; set; }
+
public virtual DbSet PimsFinancialActivityCodes { get; set; }
public virtual DbSet PimsFinancialActivityCodeHists { get; set; }
@@ -878,7 +884,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.AssignedDate)
.HasDefaultValueSql("(getutcdate())")
.HasComment("Date of file assignment.");
- entity.Property(e => e.CompletionDate).HasComment("Date of acquisition file completion.");
entity.Property(e => e.ConcurrencyControlNumber).HasDefaultValue(1L);
entity.Property(e => e.DbCreateTimestamp).HasDefaultValueSql("(getutcdate())");
entity.Property(e => e.DbCreateUserid).HasDefaultValueSql("(user_name())");
@@ -3505,6 +3510,113 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.IsDisabled).HasComment("Indicates if the code value is inactive.");
});
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.FileNumberId).HasName("FILNUM_PK");
+
+ entity.ToTable("PIMS_FILE_NUMBER", tb =>
+ {
+ tb.HasComment("Table containing the file numbers associated with a property.");
+ tb.HasTrigger("PIMS_FILNUM_A_S_IUD_TR");
+ tb.HasTrigger("PIMS_FILNUM_I_S_I_TR");
+ tb.HasTrigger("PIMS_FILNUM_I_S_U_TR");
+ });
+
+ entity.Property(e => e.FileNumberId)
+ .HasDefaultValueSql("(NEXT VALUE FOR [PIMS_FILE_NUMBER_ID_SEQ])")
+ .HasComment("Generated surrogate primary key");
+ entity.Property(e => e.AppCreateTimestamp)
+ .HasDefaultValueSql("(getutcdate())")
+ .HasComment("The date and time the user created the record.");
+ entity.Property(e => e.AppCreateUserDirectory)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The directory of the user account that created the record.");
+ entity.Property(e => e.AppCreateUserGuid).HasComment("The GUID of the user account that created the record.");
+ entity.Property(e => e.AppCreateUserid)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The user account that created the record.");
+ entity.Property(e => e.AppLastUpdateTimestamp)
+ .HasDefaultValueSql("(getutcdate())")
+ .HasComment("The date and time the user updated the record.");
+ entity.Property(e => e.AppLastUpdateUserDirectory)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The directory of the user account that updated the record.");
+ entity.Property(e => e.AppLastUpdateUserGuid).HasComment("The GUID of the user account that updated the record.");
+ entity.Property(e => e.AppLastUpdateUserid)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The user account that updated the record.");
+ entity.Property(e => e.ConcurrencyControlNumber)
+ .HasDefaultValue(1L)
+ .HasComment("Application code is responsible for retrieving the row and then incrementing the value of the CONCURRENCY_CONTROL_NUMBER column by one prior to issuing an update. If this is done then the update will succeed, provided that the row was not updated by any o");
+ entity.Property(e => e.DbCreateTimestamp)
+ .HasDefaultValueSql("(getutcdate())")
+ .HasComment("The date and time the record was created.");
+ entity.Property(e => e.DbCreateUserid)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The user or proxy account that created the record.");
+ entity.Property(e => e.DbLastUpdateTimestamp)
+ .HasDefaultValueSql("(getutcdate())")
+ .HasComment("The date and time the record was created or last updated.");
+ entity.Property(e => e.DbLastUpdateUserid)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The user or proxy account that created or last updated the record.");
+ entity.Property(e => e.FileNumber).HasComment("The file number value.");
+ entity.Property(e => e.FileNumberTypeCode).HasComment("Foreign key describing the file number type.");
+ entity.Property(e => e.IsDisabled)
+ .HasDefaultValue(false)
+ .HasComment("Indicates if the record is disabled.");
+ entity.Property(e => e.OtherFileNumberType).HasComment("Description of file number type that's not currently listed.");
+ entity.Property(e => e.PropertyId).HasComment("Foreign key to the PIMS_PROPERTY table.");
+
+ entity.HasOne(d => d.FileNumberTypeCodeNavigation).WithMany(p => p.PimsFileNumbers)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("PIM_FLNMTY_PIM_FILNUM_FK");
+
+ entity.HasOne(d => d.Property).WithMany(p => p.PimsFileNumbers)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("PIM_PRPRTY_PIM_FILNUM_FK");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.FileNumberHistId).HasName("PIMS_FILNUM_H_PK");
+
+ entity.Property(e => e.FileNumberHistId).HasDefaultValueSql("(NEXT VALUE FOR [PIMS_FILE_NUMBER_H_ID_SEQ])");
+ entity.Property(e => e.EffectiveDateHist).HasDefaultValueSql("(getutcdate())");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.FileNumberTypeCode).HasName("FLNMTY_PK");
+
+ entity.ToTable("PIMS_FILE_NUMBER_TYPE", tb =>
+ {
+ tb.HasComment("Code table to describe the type of property file number.");
+ tb.HasTrigger("PIMS_FLNMTY_I_S_I_TR");
+ tb.HasTrigger("PIMS_FLNMTY_I_S_U_TR");
+ });
+
+ entity.Property(e => e.FileNumberTypeCode).HasComment("Code representing the type of file number.");
+ entity.Property(e => e.ConcurrencyControlNumber)
+ .HasDefaultValue(1L)
+ .HasComment("Application code is responsible for retrieving the row and then incrementing the value of the CONCURRENCY_CONTROL_NUMBER column by one prior to issuing an update. If this is done then the update will succeed, provided that the row was not updated by any o");
+ entity.Property(e => e.DbCreateTimestamp)
+ .HasDefaultValueSql("(getutcdate())")
+ .HasComment("The date and time the record was created.");
+ entity.Property(e => e.DbCreateUserid)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The user or proxy account that created the record.");
+ entity.Property(e => e.DbLastUpdateTimestamp)
+ .HasDefaultValueSql("(getutcdate())")
+ .HasComment("The date and time the record was created or last updated.");
+ entity.Property(e => e.DbLastUpdateUserid)
+ .HasDefaultValueSql("(user_name())")
+ .HasComment("The user or proxy account that created or last updated the record.");
+ entity.Property(e => e.Description).HasComment("Description of the type of file number.");
+ entity.Property(e => e.DisplayOrder).HasComment("Force the display order of the codes.");
+ entity.Property(e => e.IsDisabled).HasComment("Indicates if the code is disabled.");
+ });
+
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("FINACT_PK");
@@ -5591,8 +5703,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
tb.HasTrigger("PIMS_PRPRTY_I_S_U_TR");
});
- entity.Property(e => e.PropertyId).HasDefaultValueSql("(NEXT VALUE FOR [PIMS_PROPERTY_ID_SEQ])");
+ entity.Property(e => e.PropertyId)
+ .HasDefaultValueSql("(NEXT VALUE FOR [PIMS_PROPERTY_ID_SEQ])")
+ .HasComment("Generated surrogate primary key");
entity.Property(e => e.AdditionalDetails).HasComment("Additional details about the property.");
+ entity.Property(e => e.AddressId).HasComment("Foreign key to the address table.");
entity.Property(e => e.AppCreateTimestamp).HasDefaultValueSql("(getutcdate())");
entity.Property(e => e.AppLastUpdateTimestamp).HasDefaultValueSql("(getutcdate())");
entity.Property(e => e.BandName).HasComment("Name of the Indian band.");
@@ -5603,6 +5718,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.DbLastUpdateTimestamp).HasDefaultValueSql("(getutcdate())");
entity.Property(e => e.DbLastUpdateUserid).HasDefaultValueSql("(user_name())");
entity.Property(e => e.Description).HasComment("Property description");
+ entity.Property(e => e.DistrictCode).HasComment("Foreign key to the district table.");
entity.Property(e => e.EncumbranceReason).HasComment("reason for property encumbreance");
entity.Property(e => e.FileNumber).HasComment("The (ARCS/ORCS) number identifying the Property File.");
entity.Property(e => e.FileNumberSuffix).HasComment("A suffix to distinguish between Property Files with the same number.");
@@ -5630,16 +5746,27 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.Notes).HasComment("Notes about the property");
entity.Property(e => e.Pid).HasComment("Property ID");
entity.Property(e => e.Pin).HasComment("Property number");
+ entity.Property(e => e.PphStatusTypeCode).HasComment("Foreign key to the provincial public highway status type table.");
entity.Property(e => e.PphStatusUpdateTimestamp).HasComment("Date / time that the Provincial Public Highway status was updated.");
entity.Property(e => e.PphStatusUpdateUserGuid).HasComment("GUID of the user that updated the PPH status.");
entity.Property(e => e.PphStatusUpdateUserid).HasComment("Userid that updated the Provincial Public Highway status.");
- entity.Property(e => e.PropertyClassificationTypeCode).HasDefaultValue("UNKNOWN");
+ entity.Property(e => e.PropertyAreaUnitTypeCode).HasComment("Foreign key to the property area unit type table.");
+ entity.Property(e => e.PropertyClassificationTypeCode)
+ .HasDefaultValue("UNKNOWN")
+ .HasComment("Foreign key to the proeprty classification type table.");
entity.Property(e => e.PropertyDataSourceEffectiveDate).HasComment("Date the property was officially registered");
+ entity.Property(e => e.PropertyDataSourceTypeCode).HasComment("Foreign key to the property data source type table.");
+ entity.Property(e => e.PropertyStatusTypeCode).HasComment("Foreign key to the property status type table.");
+ entity.Property(e => e.PropertyTypeCode).HasComment("Foreign key to the proprty type table.");
+ entity.Property(e => e.RegionCode).HasComment("Foreign key to the region table.");
entity.Property(e => e.ReserveName).HasComment("Name of the Indian reserve.");
entity.Property(e => e.SurplusDeclarationComment).HasComment("Comment regarding the surplus declaration");
entity.Property(e => e.SurplusDeclarationDate).HasComment("Date the property was declared surplus");
+ entity.Property(e => e.SurplusDeclarationTypeCode).HasComment("Foreign key to the surplus declaration type table.");
entity.Property(e => e.SurveyPlanNumber).HasComment("Property/Land Parcel survey plan number");
+ entity.Property(e => e.VolumeUnitTypeCode).HasComment("Foreign key to the volume unit type table.");
entity.Property(e => e.VolumetricMeasurement).HasComment("Volumetric measurement of the parcel.");
+ entity.Property(e => e.VolumetricTypeCode).HasComment("Foreign key to the volumetric type table.");
entity.Property(e => e.Zoning).HasComment("Current property zoning");
entity.Property(e => e.ZoningPotential).HasComment("Potential property zoning");
@@ -7916,6 +8043,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.HasSequence("PIMS_FILE_ENTITY_PERMISSIONS_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
+ modelBuilder.HasSequence("PIMS_FILE_NUMBER_H_ID_SEQ")
+ .HasMin(1L)
+ .HasMax(2147483647L);
+ modelBuilder.HasSequence("PIMS_FILE_NUMBER_ID_SEQ")
+ .HasMin(1L)
+ .HasMax(2147483647L);
modelBuilder.HasSequence("PIMS_FINANCIAL_ACTIVITY_CODE_H_ID_SEQ")
.HasMin(1L)
.HasMax(2147483647L);
diff --git a/source/backend/entities/ef/PimsAcquisitionFile.cs b/source/backend/entities/ef/PimsAcquisitionFile.cs
index d05630de96..0289e01fb8 100644
--- a/source/backend/entities/ef/PimsAcquisitionFile.cs
+++ b/source/backend/entities/ef/PimsAcquisitionFile.cs
@@ -110,12 +110,6 @@ public partial class PimsAcquisitionFile
[Column("DELIVERY_DATE", TypeName = "datetime")]
public DateTime? DeliveryDate { get; set; }
- ///
- /// Date of acquisition file completion.
- ///
- [Column("COMPLETION_DATE", TypeName = "datetime")]
- public DateTime? CompletionDate { get; set; }
-
///
/// Legacy Acquisition File ID from the PAIMS system.
///
diff --git a/source/backend/entities/ef/PimsAcquisitionFileHist.cs b/source/backend/entities/ef/PimsAcquisitionFileHist.cs
index de58763626..13e4ee3ea3 100644
--- a/source/backend/entities/ef/PimsAcquisitionFileHist.cs
+++ b/source/backend/entities/ef/PimsAcquisitionFileHist.cs
@@ -81,9 +81,6 @@ public partial class PimsAcquisitionFileHist
[Column("DELIVERY_DATE", TypeName = "datetime")]
public DateTime? DeliveryDate { get; set; }
- [Column("COMPLETION_DATE", TypeName = "datetime")]
- public DateTime? CompletionDate { get; set; }
-
[Column("PAIMS_ACQUISITION_FILE_ID")]
public int? PaimsAcquisitionFileId { get; set; }
@@ -140,4 +137,7 @@ public partial class PimsAcquisitionFileHist
[Column("DB_LAST_UPDATE_USERID")]
[StringLength(30)]
public string DbLastUpdateUserid { get; set; }
+
+ [Column("COMPLETION_DATE", TypeName = "datetime")]
+ public DateTime? CompletionDate { get; set; }
}
diff --git a/source/backend/entities/ef/PimsFileNumber.cs b/source/backend/entities/ef/PimsFileNumber.cs
new file mode 100644
index 0000000000..12e54b06d6
--- /dev/null
+++ b/source/backend/entities/ef/PimsFileNumber.cs
@@ -0,0 +1,156 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using Microsoft.EntityFrameworkCore;
+
+namespace Pims.Dal.Entities;
+
+///
+/// Table containing the file numbers associated with a property.
+///
+[Table("PIMS_FILE_NUMBER")]
+[Index("FileNumber", Name = "FILNUM_FILE_NUMBER_IDX")]
+[Index("PropertyId", Name = "FILNUM_PROPERTY_ID_IDX")]
+public partial class PimsFileNumber
+{
+ ///
+ /// Generated surrogate primary key
+ ///
+ [Key]
+ [Column("FILE_NUMBER_ID")]
+ public long FileNumberId { get; set; }
+
+ ///
+ /// Foreign key to the PIMS_PROPERTY table.
+ ///
+ [Column("PROPERTY_ID")]
+ public long PropertyId { get; set; }
+
+ ///
+ /// Foreign key describing the file number type.
+ ///
+ [Required]
+ [Column("FILE_NUMBER_TYPE_CODE")]
+ [StringLength(20)]
+ public string FileNumberTypeCode { get; set; }
+
+ ///
+ /// The file number value.
+ ///
+ [Required]
+ [Column("FILE_NUMBER")]
+ [StringLength(500)]
+ public string FileNumber { get; set; }
+
+ ///
+ /// Description of file number type that's not currently listed.
+ ///
+ [Column("OTHER_FILE_NUMBER_TYPE")]
+ [StringLength(200)]
+ public string OtherFileNumberType { get; set; }
+
+ ///
+ /// Indicates if the record is disabled.
+ ///
+ [Column("IS_DISABLED")]
+ public bool? IsDisabled { get; set; }
+
+ ///
+ /// Application code is responsible for retrieving the row and then incrementing the value of the CONCURRENCY_CONTROL_NUMBER column by one prior to issuing an update. If this is done then the update will succeed, provided that the row was not updated by any o
+ ///
+ [Column("CONCURRENCY_CONTROL_NUMBER")]
+ public long ConcurrencyControlNumber { get; set; }
+
+ ///
+ /// The date and time the user created the record.
+ ///
+ [Column("APP_CREATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime AppCreateTimestamp { get; set; }
+
+ ///
+ /// The user account that created the record.
+ ///
+ [Required]
+ [Column("APP_CREATE_USERID")]
+ [StringLength(30)]
+ public string AppCreateUserid { get; set; }
+
+ ///
+ /// The GUID of the user account that created the record.
+ ///
+ [Column("APP_CREATE_USER_GUID")]
+ public Guid? AppCreateUserGuid { get; set; }
+
+ ///
+ /// The directory of the user account that created the record.
+ ///
+ [Required]
+ [Column("APP_CREATE_USER_DIRECTORY")]
+ [StringLength(30)]
+ public string AppCreateUserDirectory { get; set; }
+
+ ///
+ /// The date and time the user updated the record.
+ ///
+ [Column("APP_LAST_UPDATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime AppLastUpdateTimestamp { get; set; }
+
+ ///
+ /// The user account that updated the record.
+ ///
+ [Required]
+ [Column("APP_LAST_UPDATE_USERID")]
+ [StringLength(30)]
+ public string AppLastUpdateUserid { get; set; }
+
+ ///
+ /// The GUID of the user account that updated the record.
+ ///
+ [Column("APP_LAST_UPDATE_USER_GUID")]
+ public Guid? AppLastUpdateUserGuid { get; set; }
+
+ ///
+ /// The directory of the user account that updated the record.
+ ///
+ [Required]
+ [Column("APP_LAST_UPDATE_USER_DIRECTORY")]
+ [StringLength(30)]
+ public string AppLastUpdateUserDirectory { get; set; }
+
+ ///
+ /// The date and time the record was created.
+ ///
+ [Column("DB_CREATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime DbCreateTimestamp { get; set; }
+
+ ///
+ /// The user or proxy account that created the record.
+ ///
+ [Required]
+ [Column("DB_CREATE_USERID")]
+ [StringLength(30)]
+ public string DbCreateUserid { get; set; }
+
+ ///
+ /// The date and time the record was created or last updated.
+ ///
+ [Column("DB_LAST_UPDATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime DbLastUpdateTimestamp { get; set; }
+
+ ///
+ /// The user or proxy account that created or last updated the record.
+ ///
+ [Required]
+ [Column("DB_LAST_UPDATE_USERID")]
+ [StringLength(30)]
+ public string DbLastUpdateUserid { get; set; }
+
+ [ForeignKey("FileNumberTypeCode")]
+ [InverseProperty("PimsFileNumbers")]
+ public virtual PimsFileNumberType FileNumberTypeCodeNavigation { get; set; }
+
+ [ForeignKey("PropertyId")]
+ [InverseProperty("PimsFileNumbers")]
+ public virtual PimsProperty Property { get; set; }
+}
diff --git a/source/backend/entities/ef/PimsFileNumberHist.cs b/source/backend/entities/ef/PimsFileNumberHist.cs
new file mode 100644
index 0000000000..6a8dd58991
--- /dev/null
+++ b/source/backend/entities/ef/PimsFileNumberHist.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using Microsoft.EntityFrameworkCore;
+
+namespace Pims.Dal.Entities;
+
+[Table("PIMS_FILE_NUMBER_HIST")]
+[Index("FileNumberHistId", "EndDateHist", Name = "PIMS_FILNUM_H_UK", IsUnique = true)]
+public partial class PimsFileNumberHist
+{
+ [Key]
+ [Column("_FILE_NUMBER_HIST_ID")]
+ public long FileNumberHistId { get; set; }
+
+ [Column("EFFECTIVE_DATE_HIST", TypeName = "datetime")]
+ public DateTime EffectiveDateHist { get; set; }
+
+ [Column("END_DATE_HIST", TypeName = "datetime")]
+ public DateTime? EndDateHist { get; set; }
+
+ [Column("FILE_NUMBER_ID")]
+ public long FileNumberId { get; set; }
+
+ [Column("PROPERTY_ID")]
+ public long PropertyId { get; set; }
+
+ [Required]
+ [Column("FILE_NUMBER_TYPE_CODE")]
+ [StringLength(20)]
+ public string FileNumberTypeCode { get; set; }
+
+ [Required]
+ [Column("FILE_NUMBER")]
+ [StringLength(500)]
+ public string FileNumber { get; set; }
+
+ [Column("OTHER_FILE_NUMBER_TYPE")]
+ [StringLength(200)]
+ public string OtherFileNumberType { get; set; }
+
+ [Column("IS_DISABLED")]
+ public bool? IsDisabled { get; set; }
+
+ [Column("CONCURRENCY_CONTROL_NUMBER")]
+ public long ConcurrencyControlNumber { get; set; }
+
+ [Column("APP_CREATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime AppCreateTimestamp { get; set; }
+
+ [Required]
+ [Column("APP_CREATE_USERID")]
+ [StringLength(30)]
+ public string AppCreateUserid { get; set; }
+
+ [Column("APP_CREATE_USER_GUID")]
+ public Guid? AppCreateUserGuid { get; set; }
+
+ [Required]
+ [Column("APP_CREATE_USER_DIRECTORY")]
+ [StringLength(30)]
+ public string AppCreateUserDirectory { get; set; }
+
+ [Column("APP_LAST_UPDATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime AppLastUpdateTimestamp { get; set; }
+
+ [Required]
+ [Column("APP_LAST_UPDATE_USERID")]
+ [StringLength(30)]
+ public string AppLastUpdateUserid { get; set; }
+
+ [Column("APP_LAST_UPDATE_USER_GUID")]
+ public Guid? AppLastUpdateUserGuid { get; set; }
+
+ [Required]
+ [Column("APP_LAST_UPDATE_USER_DIRECTORY")]
+ [StringLength(30)]
+ public string AppLastUpdateUserDirectory { get; set; }
+
+ [Column("DB_CREATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime DbCreateTimestamp { get; set; }
+
+ [Required]
+ [Column("DB_CREATE_USERID")]
+ [StringLength(30)]
+ public string DbCreateUserid { get; set; }
+
+ [Column("DB_LAST_UPDATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime DbLastUpdateTimestamp { get; set; }
+
+ [Required]
+ [Column("DB_LAST_UPDATE_USERID")]
+ [StringLength(30)]
+ public string DbLastUpdateUserid { get; set; }
+}
diff --git a/source/backend/entities/ef/PimsFileNumberType.cs b/source/backend/entities/ef/PimsFileNumberType.cs
new file mode 100644
index 0000000000..38bba76f6b
--- /dev/null
+++ b/source/backend/entities/ef/PimsFileNumberType.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using Microsoft.EntityFrameworkCore;
+
+namespace Pims.Dal.Entities;
+
+///
+/// Code table to describe the type of property file number.
+///
+[Table("PIMS_FILE_NUMBER_TYPE")]
+public partial class PimsFileNumberType
+{
+ ///
+ /// Code representing the type of file number.
+ ///
+ [Key]
+ [Column("FILE_NUMBER_TYPE_CODE")]
+ [StringLength(20)]
+ public string FileNumberTypeCode { get; set; }
+
+ ///
+ /// Description of the type of file number.
+ ///
+ [Required]
+ [Column("DESCRIPTION")]
+ [StringLength(200)]
+ public string Description { get; set; }
+
+ ///
+ /// Indicates if the code is disabled.
+ ///
+ [Column("IS_DISABLED")]
+ public bool IsDisabled { get; set; }
+
+ ///
+ /// Force the display order of the codes.
+ ///
+ [Column("DISPLAY_ORDER")]
+ public int? DisplayOrder { get; set; }
+
+ ///
+ /// Application code is responsible for retrieving the row and then incrementing the value of the CONCURRENCY_CONTROL_NUMBER column by one prior to issuing an update. If this is done then the update will succeed, provided that the row was not updated by any o
+ ///
+ [Column("CONCURRENCY_CONTROL_NUMBER")]
+ public long ConcurrencyControlNumber { get; set; }
+
+ ///
+ /// The date and time the record was created.
+ ///
+ [Column("DB_CREATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime DbCreateTimestamp { get; set; }
+
+ ///
+ /// The user or proxy account that created the record.
+ ///
+ [Required]
+ [Column("DB_CREATE_USERID")]
+ [StringLength(30)]
+ public string DbCreateUserid { get; set; }
+
+ ///
+ /// The date and time the record was created or last updated.
+ ///
+ [Column("DB_LAST_UPDATE_TIMESTAMP", TypeName = "datetime")]
+ public DateTime DbLastUpdateTimestamp { get; set; }
+
+ ///
+ /// The user or proxy account that created or last updated the record.
+ ///
+ [Required]
+ [Column("DB_LAST_UPDATE_USERID")]
+ [StringLength(30)]
+ public string DbLastUpdateUserid { get; set; }
+
+ [InverseProperty("FileNumberTypeCodeNavigation")]
+ public virtual ICollection PimsFileNumbers { get; set; } = new List();
+}
diff --git a/source/backend/entities/ef/PimsProperty.cs b/source/backend/entities/ef/PimsProperty.cs
index a10d5f8619..07621f0630 100644
--- a/source/backend/entities/ef/PimsProperty.cs
+++ b/source/backend/entities/ef/PimsProperty.cs
@@ -29,55 +29,94 @@ namespace Pims.Dal.Entities;
[Index("VolumeUnitTypeCode", Name = "PRPRTY_VOLUME_UNIT_TYPE_CODE_IDX")]
public partial class PimsProperty
{
+ ///
+ /// Generated surrogate primary key
+ ///
[Key]
[Column("PROPERTY_ID")]
public long PropertyId { get; set; }
+ ///
+ /// Foreign key to the proprty type table.
+ ///
[Required]
[Column("PROPERTY_TYPE_CODE")]
[StringLength(20)]
public string PropertyTypeCode { get; set; }
+ ///
+ /// Foreign key to the address table.
+ ///
[Column("ADDRESS_ID")]
public long? AddressId { get; set; }
+ ///
+ /// Foreign key to the region table.
+ ///
[Column("REGION_CODE")]
public short RegionCode { get; set; }
+ ///
+ /// Foreign key to the district table.
+ ///
[Column("DISTRICT_CODE")]
public short DistrictCode { get; set; }
+ ///
+ /// Foreign key to the property area unit type table.
+ ///
[Column("PROPERTY_AREA_UNIT_TYPE_CODE")]
[StringLength(20)]
public string PropertyAreaUnitTypeCode { get; set; }
+ ///
+ /// Foreign key to the property data source type table.
+ ///
[Required]
[Column("PROPERTY_DATA_SOURCE_TYPE_CODE")]
[StringLength(20)]
public string PropertyDataSourceTypeCode { get; set; }
+ ///
+ /// Foreign key to the property status type table.
+ ///
[Required]
[Column("PROPERTY_STATUS_TYPE_CODE")]
[StringLength(20)]
public string PropertyStatusTypeCode { get; set; }
+ ///
+ /// Foreign key to the surplus declaration type table.
+ ///
[Required]
[Column("SURPLUS_DECLARATION_TYPE_CODE")]
[StringLength(20)]
public string SurplusDeclarationTypeCode { get; set; }
+ ///
+ /// Foreign key to the volumetric type table.
+ ///
[Column("VOLUMETRIC_TYPE_CODE")]
[StringLength(20)]
public string VolumetricTypeCode { get; set; }
+ ///
+ /// Foreign key to the volume unit type table.
+ ///
[Column("VOLUME_UNIT_TYPE_CODE")]
[StringLength(20)]
public string VolumeUnitTypeCode { get; set; }
+ ///
+ /// Foreign key to the provincial public highway status type table.
+ ///
[Column("PPH_STATUS_TYPE_CODE")]
[StringLength(20)]
public string PphStatusTypeCode { get; set; }
+ ///
+ /// Foreign key to the proeprty classification type table.
+ ///
[Required]
[Column("PROPERTY_CLASSIFICATION_TYPE_CODE")]
[StringLength(20)]
@@ -375,6 +414,9 @@ public partial class PimsProperty
[InverseProperty("Property")]
public virtual ICollection PimsDispositionFileProperties { get; set; } = new List();
+ [InverseProperty("Property")]
+ public virtual ICollection PimsFileNumbers { get; set; } = new List();
+
[InverseProperty("Property")]
public virtual ICollection PimsPropPropActivities { get; set; } = new List();
diff --git a/source/backend/tests/core/Entities/TakeHelper.cs b/source/backend/tests/core/Entities/TakeHelper.cs
new file mode 100644
index 0000000000..9621a7e3cb
--- /dev/null
+++ b/source/backend/tests/core/Entities/TakeHelper.cs
@@ -0,0 +1,40 @@
+using Pims.Dal.Entities;
+using System;
+using Entity = Pims.Dal.Entities;
+
+namespace Pims.Core.Test
+{
+ ///
+ /// EntityHelper static class, provides helper methods to create test entities.
+ ///
+ public static partial class EntityHelper
+ {
+ ///
+ /// Create a new instance of a Take.
+ ///
+ ///
+ ///
+ public static Entity.PimsTake CreateTake(long id = 1)
+ {
+ return new Entity.PimsTake()
+ {
+ Internal_Id = id,
+ TakeId = id,
+ AppCreateTimestamp = DateTime.Now,
+ AppCreateUserid = "admin",
+ AppCreateUserDirectory = string.Empty,
+ AppLastUpdateUserDirectory = string.Empty,
+ AppLastUpdateUserid = string.Empty,
+ DbCreateUserid = string.Empty,
+ DbLastUpdateUserid = string.Empty,
+ ConcurrencyControlNumber = 1,
+ AreaUnitTypeCodeNavigation = new Entity.PimsAreaUnitType() { Id = id.ToString(), DbCreateUserid = "test", DbLastUpdateUserid = "test", AreaUnitTypeCode = "test", Description = "test" },
+ LandActTypeCodeNavigation = new Entity.PimsLandActType() { Id = id.ToString(), DbCreateUserid = "test", DbLastUpdateUserid = "test", LandActTypeCode = "test", Description = "test" },
+ TakeSiteContamTypeCodeNavigation = new PimsTakeSiteContamType() { Id = id.ToString(), DbCreateUserid = "test", DbLastUpdateUserid = "test", TakeSiteContamTypeCode = "test", Description = "test" },
+ TakeStatusTypeCodeNavigation = new PimsTakeStatusType() { Id = id.ToString(), DbCreateUserid = "test", DbLastUpdateUserid = "test", TakeStatusTypeCode = "test", Description = "test" },
+ TakeTypeCodeNavigation = new PimsTakeType() { Id = id.ToString(), DbCreateUserid = "test", DbLastUpdateUserid = "test", TakeTypeCode = "test", Description = "test" },
+ PropertyAcquisitionFile = new PimsPropertyAcquisitionFile(),
+ };
+ }
+ }
+}
diff --git a/source/backend/tests/unit/api/Controllers/Takes/TakeControllerTest.cs b/source/backend/tests/unit/api/Controllers/Takes/TakeControllerTest.cs
new file mode 100644
index 0000000000..55bafd40c6
--- /dev/null
+++ b/source/backend/tests/unit/api/Controllers/Takes/TakeControllerTest.cs
@@ -0,0 +1,221 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using FluentAssertions;
+using MapsterMapper;
+using Microsoft.AspNetCore.Mvc;
+using Moq;
+using Pims.Api.Areas.Admin.Controllers;
+using Pims.Api.Areas.Takes.Controllers;
+using Pims.Api.Models.Concepts.Take;
+using Pims.Api.Models.Concepts;
+using Pims.Api.Services;
+using Pims.Core.Exceptions;
+using Pims.Core.Test;
+using Pims.Dal.Entities;
+using Pims.Dal.Security;
+using Xunit;
+using System;
+using Pims.Api.Helpers.Exceptions;
+using Pims.Dal.Exceptions;
+
+namespace Pims.Api.Test.Controllers
+{
+ [Trait("category", "unit")]
+ [Trait("category", "api")]
+ [Trait("area", "takes")]
+ [ExcludeFromCodeCoverage]
+ public class TakeControllerTest
+ {
+ // xUnit.net creates a new instance of the test class for every test that is run,
+ // so any code which is placed into the constructor of the test class will be run for every single test.
+ private readonly TestHelper _helper;
+ private readonly TakeController _controller;
+ private readonly Mock _service;
+ private readonly IMapper _mapper;
+
+ public TakeControllerTest()
+ {
+ this._helper = new TestHelper();
+ this._controller = this._helper.CreateController(Permissions.PropertyView, Permissions.AcquisitionFileView);
+ this._service = this._helper.GetService>();
+ this._mapper = this._helper.GetService();
+ }
+
+ [Fact]
+ public void GetTakesByAcquisitionFileId_Success()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetByFileId(It.IsAny()));
+
+ // Act
+ var result = this._controller.GetTakesByAcquisitionFileId(1);
+
+ // Assert
+ result.Should().BeOfType();
+ this._service.Verify(m => m.GetByFileId(It.IsAny()), Times.Once());
+ }
+
+ [Fact]
+ public void GetTakesByPropertyId_Success()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetByPropertyId(It.IsAny(), It.IsAny()));
+
+ // Act
+ var result = this._controller.GetTakesByPropertyId(1, 2);
+
+ // Assert
+ result.Should().BeOfType();
+ this._service.Verify(m => m.GetByPropertyId(It.IsAny(), It.IsAny()), Times.Once());
+ }
+
+ [Fact]
+ public void GetTakesCountByPropertyId_Success()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetCountByPropertyId(It.IsAny()));
+
+ // Act
+ var result = this._controller.GetTakesCountByPropertyId(1);
+
+ // Assert
+ result.Should().BeOfType();
+ this._service.Verify(m => m.GetCountByPropertyId(It.IsAny()), Times.Once());
+ }
+
+ [Fact]
+ public void GetTakeById_Success()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetById(It.IsAny())).Returns(new PimsTake() { PropertyAcquisitionFileId = 1 });
+
+ // Act
+ var result = this._controller.GetTakeByPropertyFileId(1, 1);
+
+ // Assert
+ result.Should().BeOfType();
+ this._service.Verify(m => m.GetById(It.IsAny()));
+ }
+
+ [Fact]
+ public void GetTakeById_InvalidId()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetById(It.IsAny())).Returns(new PimsTake() { PropertyAcquisitionFileId = 2 });
+
+ // Act
+ Action act = () => this._controller.GetTakeByPropertyFileId(1, 1);
+
+ // Assert
+ act.Should().Throw().WithMessage("Invalid acquisition file property id.");
+ }
+
+ [Fact]
+ public void UpdateTakeByPropertyId_InvalidFilePropertyId()
+ {
+ // Arrange
+ this._service.Setup(m => m.UpdateAcquisitionPropertyTake(It.IsAny(), It.IsAny()));
+
+ // Act
+ Action act = () => this._controller.UpdateAcquisitionPropertyTake(1, 1, new TakeModel() { Id = 1 });
+
+ // Assert
+ act.Should().Throw().WithMessage("Invalid acquisition file property id.");
+ }
+
+ [Fact]
+ public void UpdateTakeByPropertyId_InvalidTakeId()
+ {
+ // Arrange
+ this._service.Setup(m => m.UpdateAcquisitionPropertyTake(It.IsAny(), It.IsAny()));
+
+ // Act
+ Action act = () => this._controller.UpdateAcquisitionPropertyTake(1, 1, new TakeModel() { PropertyAcquisitionFileId = 1 });
+
+ // Assert
+ act.Should().Throw().WithMessage("Invalid take id.");
+ }
+
+ [Fact]
+ public void UpdateTakeByPropertyId_Success()
+ {
+ // Arrange
+ this._service.Setup(m => m.UpdateAcquisitionPropertyTake(It.IsAny(), It.IsAny()));
+
+ // Act
+ var result = this._controller.UpdateAcquisitionPropertyTake(1, 1, new TakeModel() { PropertyAcquisitionFileId = 1, Id = 1 });
+
+ // Assert
+ result.Should().BeOfType();
+ this._service.Verify(m => m.UpdateAcquisitionPropertyTake(It.IsAny(), It.IsAny()));
+ }
+
+ [Fact]
+ public void DeleteTakeByPropertyId_Invalid_AcquisitionFilePropertyId()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetById(It.IsAny())).Returns(new PimsTake() { PropertyAcquisitionFileId = 2 });
+
+ // Act
+ Action act = () => this._controller.DeleteAcquisitionPropertyTake(1, 1, new string[0]);
+
+ // Assert
+ act.Should().Throw().WithMessage("Invalid acquisition file property id.");
+ }
+
+ [Fact]
+ public void DeleteTakeByPropertyId_Failed_Delete()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetById(It.IsAny())).Returns(new PimsTake() { PropertyAcquisitionFileId = 1 });
+ this._service.Setup(m => m.DeleteAcquisitionPropertyTake(It.IsAny(), It.IsAny>())).Returns(false);
+
+ // Act
+ Action act = () => this._controller.DeleteAcquisitionPropertyTake(1, 1, new string[0]);
+
+ // Assert
+ act.Should().Throw().WithMessage("Failed to delete take 1.");
+ }
+
+ [Fact]
+ public void DeleteTakeByPropertyId_Success()
+ {
+ // Arrange
+ this._service.Setup(m => m.GetById(It.IsAny())).Returns(new PimsTake() { PropertyAcquisitionFileId = 1 });
+ this._service.Setup(m => m.DeleteAcquisitionPropertyTake(It.IsAny(), It.IsAny>())).Returns(true);
+
+ // Act
+ this._controller.DeleteAcquisitionPropertyTake(1, 1, new string[0]);
+
+ // Assert
+ this._service.Verify(m => m.DeleteAcquisitionPropertyTake(It.IsAny(), It.IsAny>()));
+ }
+
+ [Fact]
+ public void AddTakeByPropertyId_InvalidId()
+ {
+ // Arrange
+ this._service.Setup(m => m.AddAcquisitionPropertyTake(It.IsAny(), It.IsAny()));
+
+ // Act
+ Action act = () => this._controller.AddAcquisitionPropertyTake(1, new TakeModel());
+
+ // Assert
+ act.Should().Throw().WithMessage("Invalid acquisition file property id.");
+ }
+
+ [Fact]
+ public void AddTakeByPropertyId_Success()
+ {
+ // Arrange
+ this._service.Setup(m => m.AddAcquisitionPropertyTake(It.IsAny(), It.IsAny()));
+
+ // Act
+ var result = this._controller.AddAcquisitionPropertyTake(1, new TakeModel() { PropertyAcquisitionFileId = 1 });
+
+ // Assert
+ result.Should().BeOfType();
+ this._service.Verify(m => m.AddAcquisitionPropertyTake(It.IsAny(), It.IsAny()));
+ }
+ }
+}
diff --git a/source/backend/tests/unit/api/Controllers/Takes/TakesControllerTest.cs b/source/backend/tests/unit/api/Controllers/Takes/TakesControllerTest.cs
deleted file mode 100644
index 5767b9feb9..0000000000
--- a/source/backend/tests/unit/api/Controllers/Takes/TakesControllerTest.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using FluentAssertions;
-using MapsterMapper;
-using Microsoft.AspNetCore.Mvc;
-using Moq;
-using Pims.Api.Areas.Admin.Controllers;
-using Pims.Api.Areas.Takes.Controllers;
-using Pims.Api.Models.Concepts.Take;
-using Pims.Api.Models.Concepts;
-using Pims.Api.Services;
-using Pims.Core.Exceptions;
-using Pims.Core.Test;
-using Pims.Dal.Entities;
-using Pims.Dal.Security;
-using Xunit;
-
-namespace Pims.Api.Test.Controllers
-{
- [Trait("category", "unit")]
- [Trait("category", "api")]
- [Trait("area", "takes")]
- [ExcludeFromCodeCoverage]
- public class TakesControllerTest
- {
- // xUnit.net creates a new instance of the test class for every test that is run,
- // so any code which is placed into the constructor of the test class will be run for every single test.
- private readonly TestHelper _helper;
- private readonly TakeController _controller;
- private readonly Mock _service;
- private readonly IMapper _mapper;
-
- public TakesControllerTest()
- {
- this._helper = new TestHelper();
- this._controller = this._helper.CreateController(Permissions.PropertyView, Permissions.AcquisitionFileView);
- this._service = this._helper.GetService>();
- this._mapper = this._helper.GetService();
- }
-
- [Fact]
- public void GetTakesByAcquisitionFileId_Success()
- {
- // Arrange
- this._service.Setup(m => m.GetByFileId(It.IsAny()));
-
- // Act
- var result = this._controller.GetTakesByAcquisitionFileId(1);
-
- // Assert
- result.Should().BeOfType();
- this._service.Verify(m => m.GetByFileId(It.IsAny()), Times.Once());
- }
-
- [Fact]
- public void GetTakesByPropertyId_Success()
- {
- // Arrange
- this._service.Setup(m => m.GetByPropertyId(It.IsAny(), It.IsAny()));
-
- // Act
- var result = this._controller.GetTakesByPropertyId(1, 2);
-
- // Assert
- result.Should().BeOfType();
- this._service.Verify(m => m.GetByPropertyId(It.IsAny(), It.IsAny()), Times.Once());
- }
-
- [Fact]
- public void GetTakesCountByPropertyId_Success()
- {
- // Arrange
- this._service.Setup(m => m.GetCountByPropertyId(It.IsAny()));
-
- // Act
- var result = this._controller.GetTakesCountByPropertyId(1);
-
- // Assert
- result.Should().BeOfType();
- this._service.Verify(m => m.GetCountByPropertyId(It.IsAny()), Times.Once());
- }
-
- [Fact]
- public void UpdateAcquisitionPropertyTakes_Success()
- {
- // Arrange
- this._service.Setup(m => m.UpdateAcquisitionPropertyTakes(It.IsAny(), It.IsAny>()));
-
- // Act
- var result = this._controller.UpdateAcquisitionPropertyTakes(1, new List());
-
- // Assert
- result.Should().BeOfType();
- this._service.Verify(m => m.UpdateAcquisitionPropertyTakes(It.IsAny(), It.IsAny>()));
- }
- }
-}
diff --git a/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs b/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs
index 287ef77fc2..24e2ee0f18 100644
--- a/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs
+++ b/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs
@@ -1540,7 +1540,7 @@ public void UpdateProperties_Final()
// Assert
var exception = act.Should().Throw();
- exception.WithMessage("The file you are editing is not active or draft, so you cannot save changes. Refresh your browser to see file state.");
+ exception.WithMessage("The file you are editing is not active or hold, so you cannot save changes. Refresh your browser to see file state.");
}
[Fact]
diff --git a/source/backend/tests/unit/api/Services/DispositionFileServiceTest.cs b/source/backend/tests/unit/api/Services/DispositionFileServiceTest.cs
index d218a54f75..a99d4b837d 100644
--- a/source/backend/tests/unit/api/Services/DispositionFileServiceTest.cs
+++ b/source/backend/tests/unit/api/Services/DispositionFileServiceTest.cs
@@ -13,6 +13,7 @@
using NExpect.Interfaces;
using Pims.Api.Constants;
using Pims.Api.Helpers.Exceptions;
+using Pims.Api.Models.CodeTypes;
using Pims.Api.Models.Concepts;
using Pims.Api.Services;
using Pims.Core.Exceptions;
@@ -391,7 +392,7 @@ public void Update_Should_Fail_Duplicate_Team()
var repository = this._helper.GetService>();
var statusMock = this._helper.GetService>();
- statusMock.Setup(x => x.CanEditDetails(It.IsAny())).Returns(true);
+ statusMock.Setup(x => x.CanEditDetails(It.IsAny())).Returns(true);
var dispFile = EntityHelper.CreateDispositionFile(1);
@@ -416,7 +417,7 @@ public void Update_Should_Fail_Region_Validation()
var repository = this._helper.GetService>();
var statusMock = this._helper.GetService>();
- statusMock.Setup(x => x.CanEditDetails(It.IsAny())).Returns(true);
+ statusMock.Setup(x => x.CanEditDetails(It.IsAny())).Returns(true);
var dispFile = EntityHelper.CreateDispositionFile(1);
dispFile.PimsDispositionSales = new List() { new PimsDispositionSale() { SaleFinalAmt = 1 } };
@@ -437,14 +438,14 @@ public void Update_Should_Fail_Region_Validation()
public static IEnumerable