diff --git a/.github/workflows/api-dotnetcore.yml b/.github/workflows/api-dotnetcore.yml
index 7f24c8ce96..2b8394a6a9 100644
--- a/.github/workflows/api-dotnetcore.yml
+++ b/.github/workflows/api-dotnetcore.yml
@@ -30,12 +30,16 @@ jobs:
matrix:
services:
[
- { directory: ./source/backend/api, solution: "Pims.sln" },
- { directory: ./source/backend/proxy, solution: "Proxy.sln" },
+ { directory: ./source/backend/api, solution: "Pims.Api.csproj" },
+ {
+ directory: ./source/backend/proxy,
+ solution: "Pims.Proxy.csproj",
+ },
{
directory: ./source/backend/scheduler,
- solution: "Scheduler.sln",
+ solution: "Pims.Scheduler.csproj",
},
+ { directory: ./source/backend/tests, solution: "PimsUnitTest.sln" },
]
env:
working-directory: ${{ matrix.services.directory }}
@@ -65,12 +69,13 @@ jobs:
working-directory: ${{env.working-directory}}
- name: Install coverlet for code coverage
+ if: ${{ env.solution-name == 'PimsUnitTest.sln' }}
run: dotnet tool install -g coverlet.console --version 1.7.2
working-directory: ${{env.working-directory}}
- name: Test
- if: ${{ env.solution-name == 'Pims.sln' }}
- run: dotnet test Pims.sln --no-restore --verbosity normal
+ if: ${{ env.solution-name == 'PimsUnitTest.sln' }}
+ run: dotnet test PimsUnitTest.sln --no-restore --verbosity normal
working-directory: ${{env.working-directory}}
# For future reference, if we have N test projects the flow of events would be:
@@ -97,41 +102,44 @@ jobs:
#
# The final `coverage.opencover.xml` is the one we want
- name: Generate code coverage
- if: ${{ env.solution-name == 'Pims.sln' }}
- working-directory: ${{env.working-directory}}/../tests/unit
+ if: ${{ env.solution-name == 'PimsUnitTest.sln' }}
+ working-directory: ${{env.working-directory}}
run: |
pwd
mkdir -p TestResults
rm -rf api/TestResults
rm -rf dal/TestResults
rm -rf mockdal/TestResults
+ rm -rf scheduler/TestResults
cd api
- dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore > out.txt
- ls
- cat out.txt
+ dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore
mv TestResults/*/* ../TestResults/
cd ..
cd dal
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore
- ls
mv TestResults/*/* ../TestResults/
cd ..
cd mockdal
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore
- ls
mv TestResults/*/* ../TestResults/
cd ..
+ cd scheduler
+ dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore
+ mv TestResults/*/* ../TestResults/
+ cd ..
+ echo "TestResults folder"
+ ls TestResults
head TestResults/coverage.opencover.xml
- name: Save PR number and scan results
- if: ${{ env.solution-name == 'Pims.sln' }}
+ if: ${{ env.solution-name == 'PimsUnitTest.sln' }}
run: |
mkdir -p ./pr
echo ${{ github.event.pull_request.number }} > ./pr/NR
- cp ${{env.working-directory}}/../tests/unit/TestResults/coverage.opencover.xml ./pr
+ cp ${{env.working-directory}}/TestResults/coverage.opencover.xml ./pr
- uses: actions/upload-artifact@v4
- if: ${{ env.solution-name == 'Pims.sln' }}
+ if: ${{ env.solution-name == 'PimsUnitTest.sln' }}
with:
name: pr-codecov
path: pr/
diff --git a/.github/workflows/deploy-prod-start-argo.yml b/.github/workflows/deploy-prod-start-argo.yml
index a947f638f5..ec586ea23b 100644
--- a/.github/workflows/deploy-prod-start-argo.yml
+++ b/.github/workflows/deploy-prod-start-argo.yml
@@ -153,4 +153,4 @@ jobs:
- name: call scripts to sync keycloak
shell: bash
run: |
- oc process -f ./openshift/4.0/templates/jobs/keycloak-sync-pipeline-run.yaml -p ASPNETCORE_ENVIRONMENT=$ASPNETCORE_ENVIRONMENT -p NAMESPACE=3cd915-prod -p BRANCH=$GIT_BRANCH -p API_URL=http://pims-api-prod:8080/api | oc create -f - | grep -oP "(?<=\/)[^\s]*" | (read PIPELINE_NAME; oc wait --for=condition=succeeded pipelineruns/$PIPELINE_NAME --timeout=500s)
+ oc process -f ./openshift/4.0/templates/jobs/keycloak-sync-pipeline-run.yaml -p ASPNETCORE_ENVIRONMENT=$ASPNETCORE_ENVIRONMENT -p NAMESPACE=3cd915-prod -p BRANCH=$GIT_BRANCH -p API_URL=http://pims-api-prod:8080/api | oc create -f - | grep -oP "(?<=\/)[^\s]*" | (read PIPELINE_NAME; oc wait --for=condition=succeeded pipelineruns/$PIPELINE_NAME --timeout=720s)
diff --git a/source/backend/Dockerfile b/source/backend/Dockerfile
index b62370980f..b5cd8f63a6 100644
--- a/source/backend/Dockerfile
+++ b/source/backend/Dockerfile
@@ -6,7 +6,6 @@ EXPOSE 5001 5000
# Copy csproj and restore as distinct layers
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
-COPY api/*.sln api/
COPY Directory.Build.props .
COPY api/*.csproj api/
COPY apimodels/*.csproj apimodels/
diff --git a/source/backend/Dockerfile.proxy b/source/backend/Dockerfile.proxy
index 31ea2b9931..12666b664d 100644
--- a/source/backend/Dockerfile.proxy
+++ b/source/backend/Dockerfile.proxy
@@ -14,7 +14,7 @@ COPY core.api core.api/
COPY keycloak keycloak/
COPY proxy/*.csproj proxy/
-RUN dotnet restore proxy/Proxy.sln
+RUN dotnet restore proxy/Pims.Proxy.csproj
ENV PATH="$PATH:/root/.dotnet/tools"
# Copy everything else and build
WORKDIR /src/proxy
diff --git a/source/backend/Dockerfile.scheduler b/source/backend/Dockerfile.scheduler
index 847c0fa060..5a2dfea8e4 100644
--- a/source/backend/Dockerfile.scheduler
+++ b/source/backend/Dockerfile.scheduler
@@ -15,7 +15,7 @@ COPY core.api core.api/
COPY keycloak keycloak/
COPY scheduler/*.csproj scheduler/
-RUN dotnet restore scheduler/Scheduler.sln
+RUN dotnet restore scheduler/Pims.Scheduler.csproj
ENV PATH="$PATH:/root/.dotnet/tools"
# Copy everything else and build
WORKDIR /src/scheduler
diff --git a/source/backend/PimsBackend.sln b/source/backend/PimsBackend.sln
new file mode 100644
index 0000000000..d27cf7e244
--- /dev/null
+++ b/source/backend/PimsBackend.sln
@@ -0,0 +1,91 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.13.35828.75
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Api", "api\Pims.Api.csproj", "{16BC0468-78F6-4C91-87DA-7403C919E646}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Dal", "dal\Pims.Dal.csproj", "{6DFFF5E1-1B87-403B-99D0-A9E03D8A8EB3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Proxy", "proxy\Pims.Proxy.csproj", "{826D3B92-8D74-43F4-AD22-398632247E37}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Dal.Entities", "entities\Pims.Dal.Entities.csproj", "{1C724CD5-CD24-46CD-835A-A83F673F97B5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Api.Models", "apimodels\Pims.Api.Models.csproj", "{58C42283-68DA-477F-915D-C67597543546}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Scheduler", "scheduler\Pims.Scheduler.csproj", "{AC4336C5-5631-4D9D-B78F-6C2DF79A6F1F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Keycloak", "keycloak\Pims.Keycloak.csproj", "{970903E9-BC53-436F-BA77-C62349546425}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Dal.Keycloak", "dal.keycloak\Pims.Dal.Keycloak.csproj", "{5697DD19-62CC-4377-ABA8-1E192376F4F6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Core", "core\Pims.Core.csproj", "{AC8F04FF-3164-41FB-9EDF-E468B8B77837}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Core.Api", "core.api\Pims.Core.Api.csproj", "{89A99CC5-ADFB-4FC2-9136-7B0029EEA2D8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Geocoder", "geocoder\Pims.Geocoder.csproj", "{BF7450E8-B3C5-46FB-BEC1-C5FC1C5964DC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Ltsa", "ltsa\Pims.Ltsa.csproj", "{1ED5DF03-7784-44EC-B02B-516167210CCF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {16BC0468-78F6-4C91-87DA-7403C919E646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {16BC0468-78F6-4C91-87DA-7403C919E646}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {16BC0468-78F6-4C91-87DA-7403C919E646}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {16BC0468-78F6-4C91-87DA-7403C919E646}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6DFFF5E1-1B87-403B-99D0-A9E03D8A8EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6DFFF5E1-1B87-403B-99D0-A9E03D8A8EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6DFFF5E1-1B87-403B-99D0-A9E03D8A8EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6DFFF5E1-1B87-403B-99D0-A9E03D8A8EB3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {826D3B92-8D74-43F4-AD22-398632247E37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {826D3B92-8D74-43F4-AD22-398632247E37}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {826D3B92-8D74-43F4-AD22-398632247E37}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {826D3B92-8D74-43F4-AD22-398632247E37}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1C724CD5-CD24-46CD-835A-A83F673F97B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1C724CD5-CD24-46CD-835A-A83F673F97B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1C724CD5-CD24-46CD-835A-A83F673F97B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1C724CD5-CD24-46CD-835A-A83F673F97B5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {58C42283-68DA-477F-915D-C67597543546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {58C42283-68DA-477F-915D-C67597543546}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {58C42283-68DA-477F-915D-C67597543546}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {58C42283-68DA-477F-915D-C67597543546}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AC4336C5-5631-4D9D-B78F-6C2DF79A6F1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AC4336C5-5631-4D9D-B78F-6C2DF79A6F1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AC4336C5-5631-4D9D-B78F-6C2DF79A6F1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AC4336C5-5631-4D9D-B78F-6C2DF79A6F1F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {970903E9-BC53-436F-BA77-C62349546425}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {970903E9-BC53-436F-BA77-C62349546425}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {970903E9-BC53-436F-BA77-C62349546425}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {970903E9-BC53-436F-BA77-C62349546425}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5697DD19-62CC-4377-ABA8-1E192376F4F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5697DD19-62CC-4377-ABA8-1E192376F4F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5697DD19-62CC-4377-ABA8-1E192376F4F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5697DD19-62CC-4377-ABA8-1E192376F4F6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AC8F04FF-3164-41FB-9EDF-E468B8B77837}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AC8F04FF-3164-41FB-9EDF-E468B8B77837}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AC8F04FF-3164-41FB-9EDF-E468B8B77837}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AC8F04FF-3164-41FB-9EDF-E468B8B77837}.Release|Any CPU.Build.0 = Release|Any CPU
+ {89A99CC5-ADFB-4FC2-9136-7B0029EEA2D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {89A99CC5-ADFB-4FC2-9136-7B0029EEA2D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {89A99CC5-ADFB-4FC2-9136-7B0029EEA2D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {89A99CC5-ADFB-4FC2-9136-7B0029EEA2D8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BF7450E8-B3C5-46FB-BEC1-C5FC1C5964DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BF7450E8-B3C5-46FB-BEC1-C5FC1C5964DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BF7450E8-B3C5-46FB-BEC1-C5FC1C5964DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BF7450E8-B3C5-46FB-BEC1-C5FC1C5964DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1ED5DF03-7784-44EC-B02B-516167210CCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1ED5DF03-7784-44EC-B02B-516167210CCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1ED5DF03-7784-44EC-B02B-516167210CCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1ED5DF03-7784-44EC-B02B-516167210CCF}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {2198DDB0-E914-4A28-B5A7-64ED4CC99E98}
+ EndGlobalSection
+EndGlobal
diff --git a/source/backend/api/Areas/Acquisition/Controllers/AcquisitionFileController.cs b/source/backend/api/Areas/Acquisition/Controllers/AcquisitionFileController.cs
index 8938e9e55a..ebd4065b0f 100644
--- a/source/backend/api/Areas/Acquisition/Controllers/AcquisitionFileController.cs
+++ b/source/backend/api/Areas/Acquisition/Controllers/AcquisitionFileController.cs
@@ -15,6 +15,7 @@
using Pims.Core.Security;
using Pims.Dal.Entities;
using Pims.Dal.Exceptions;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Acquisition.Controllers
@@ -32,6 +33,7 @@ public class AcquisitionFileController : ControllerBase
{
#region Variables
private readonly IAcquisitionFileService _acquisitionService;
+ private readonly IAcquisitionFileRepository _acquisitionRepository;
private readonly IMapper _mapper;
private readonly ILogger _logger;
#endregion
@@ -45,9 +47,10 @@ public class AcquisitionFileController : ControllerBase
///
///
///
- public AcquisitionFileController(IAcquisitionFileService acquisitionService, IMapper mapper, ILogger logger)
+ public AcquisitionFileController(IAcquisitionFileService acquisitionService, IAcquisitionFileRepository acquisitionFileRepository, IMapper mapper, ILogger logger)
{
_acquisitionService = acquisitionService;
+ _acquisitionRepository = acquisitionFileRepository;
_mapper = mapper;
_logger = logger;
}
@@ -292,6 +295,25 @@ public IActionResult GetAcquisitionFileSubFiles(long id)
return new JsonResult(_mapper.Map>(subFiles));
}
+ [HttpGet("{id:long}/historical")]
+ [Produces("application/json")]
+ [HasPermission(Permissions.AcquisitionFileView)]
+ [ProducesResponseType(typeof(AcquisitionFileModel), 200)]
+ [SwaggerOperation(Tags = new[] { "acquisition" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetAcquisitionAtTime([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(AcquisitionFileController),
+ nameof(GetAcquisitionAtTime),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var pimsAcquisition = _acquisitionRepository.GetAcquisitionAtTime(id, time);
+ return new JsonResult(_mapper.Map(pimsAcquisition));
+ }
+
#endregion
}
}
diff --git a/source/backend/api/Areas/Acquisition/Controllers/AgreementController.cs b/source/backend/api/Areas/Acquisition/Controllers/AgreementController.cs
index 2aaaf79f0a..ef60d3ef0c 100644
--- a/source/backend/api/Areas/Acquisition/Controllers/AgreementController.cs
+++ b/source/backend/api/Areas/Acquisition/Controllers/AgreementController.cs
@@ -111,7 +111,7 @@ public IActionResult AddAcquisitionFileAgreement([FromRoute] long id, [FromBody]
[Produces("application/json")]
[ProducesResponseType(typeof(AgreementModel), 200)]
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
- public IActionResult GetAcquisitionFileAgreementById([FromRoute]long id, [FromRoute]long agreementId)
+ public IActionResult GetAcquisitionFileAgreementById([FromRoute] long id, [FromRoute] long agreementId)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
diff --git a/source/backend/api/Areas/Acquisition/Controllers/SearchController.cs b/source/backend/api/Areas/Acquisition/Controllers/SearchController.cs
index f2edd21e96..9ab669f88a 100644
--- a/source/backend/api/Areas/Acquisition/Controllers/SearchController.cs
+++ b/source/backend/api/Areas/Acquisition/Controllers/SearchController.cs
@@ -8,16 +8,16 @@ namespace Pims.Api.Areas.Acquisition.Controllers
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Areas.Acquisition.Models.Search;
- using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Models.Base;
using Pims.Api.Models.Concepts.AcquisitionFile;
- using Pims.Core.Api.Policies;
using Pims.Api.Services;
+ using Pims.Core.Api.Exceptions;
+ using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
- using Pims.Dal.Entities.Models;
using Pims.Core.Security;
+ using Pims.Dal.Entities.Models;
using Swashbuckle.AspNetCore.Annotations;
///
diff --git a/source/backend/api/Areas/Admin/Controllers/AccessRequestController.cs b/source/backend/api/Areas/Admin/Controllers/AccessRequestController.cs
index f04a067f5d..01e87dfd2e 100644
--- a/source/backend/api/Areas/Admin/Controllers/AccessRequestController.cs
+++ b/source/backend/api/Areas/Admin/Controllers/AccessRequestController.cs
@@ -5,8 +5,8 @@
using Pims.Api.Models.Concepts.AccessRequest;
using Pims.Core.Api.Policies;
using Pims.Core.Json;
-using Pims.Dal.Repositories;
using Pims.Core.Security;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
using EModel = Pims.Dal.Entities.Models;
using Entity = Pims.Dal.Entities;
diff --git a/source/backend/api/Areas/Admin/Controllers/FinancialCodeController.cs b/source/backend/api/Areas/Admin/Controllers/FinancialCodeController.cs
index 2e03230f18..3695c4a4e5 100644
--- a/source/backend/api/Areas/Admin/Controllers/FinancialCodeController.cs
+++ b/source/backend/api/Areas/Admin/Controllers/FinancialCodeController.cs
@@ -2,8 +2,8 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Models.Concepts.FinancialCode;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Exceptions;
using Pims.Core.Json;
using Pims.Core.Security;
diff --git a/source/backend/api/Areas/Admin/Controllers/RoleController.cs b/source/backend/api/Areas/Admin/Controllers/RoleController.cs
index 679330d35e..bc5bbb8e59 100644
--- a/source/backend/api/Areas/Admin/Controllers/RoleController.cs
+++ b/source/backend/api/Areas/Admin/Controllers/RoleController.cs
@@ -5,8 +5,8 @@
using Pims.Api.Models.Concepts.Role;
using Pims.Core.Api.Policies;
using Pims.Core.Json;
-using Pims.Dal.Repositories;
using Pims.Core.Security;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Admin.Controllers
diff --git a/source/backend/api/Areas/Admin/Controllers/UserController.cs b/source/backend/api/Areas/Admin/Controllers/UserController.cs
index 4669e33ba0..3ab56875ae 100644
--- a/source/backend/api/Areas/Admin/Controllers/UserController.cs
+++ b/source/backend/api/Areas/Admin/Controllers/UserController.cs
@@ -6,10 +6,10 @@
using Pims.Api.Models.Concepts.User;
using Pims.Core.Api.Policies;
using Pims.Core.Json;
+using Pims.Core.Security;
using Pims.Dal.Entities;
using Pims.Dal.Entities.Models;
using Pims.Dal.Repositories;
-using Pims.Core.Security;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Admin.Controllers
diff --git a/source/backend/api/Areas/Autocomplete/Controllers/AutocompleteController.cs b/source/backend/api/Areas/Autocomplete/Controllers/AutocompleteController.cs
index c9b723aae0..ab7448fa86 100644
--- a/source/backend/api/Areas/Autocomplete/Controllers/AutocompleteController.cs
+++ b/source/backend/api/Areas/Autocomplete/Controllers/AutocompleteController.cs
@@ -4,12 +4,12 @@
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Areas.Autocomplete.Models;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
+using Pims.Core.Api.Exceptions;
using Pims.Core.Api.Policies;
+using Pims.Core.Security;
using Pims.Dal.Entities.Models;
using Pims.Dal.Repositories;
-using Pims.Core.Security;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Autocomplete.Controllers
diff --git a/source/backend/api/Areas/CompensationRequisition/Controllers/CompensationRequisitionController.cs b/source/backend/api/Areas/CompensationRequisition/Controllers/CompensationRequisitionController.cs
index d0d8bcc12c..75eb1e9288 100644
--- a/source/backend/api/Areas/CompensationRequisition/Controllers/CompensationRequisitionController.cs
+++ b/source/backend/api/Areas/CompensationRequisition/Controllers/CompensationRequisitionController.cs
@@ -267,5 +267,105 @@ public IActionResult GetCompensationRequisitionLeasePayees([FromRoute] long id)
return new JsonResult(_mapper.Map>(compReqPayees));
}
+
+ [HttpGet("{id:long}/historical")]
+ [HasPermission(Permissions.CompensationRequisitionView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(List), 200)]
+ [SwaggerOperation(Tags = new[] { "compensation-requisition" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetCompensationRequisionAtTime([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(CompensationRequisitionController),
+ nameof(GetCompensationRequisionAtTime),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var histCompReq = _compensationRequisitionService.GetCompensationRequisitionAtTime(id, time);
+
+ return new JsonResult(_mapper.Map(histCompReq));
+ }
+
+ [HttpGet("acquisition/{id:long}/properties/historical")]
+ [HasPermission(Permissions.CompensationRequisitionView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [SwaggerOperation(Tags = new[] { "compensation-requisition" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetAcquisitionCompensationRequisitionPropertiesAtTime([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(CompensationRequisitionController),
+ nameof(GetAcquisitionCompensationRequisitionPropertiesAtTime),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var acqCompReqProperties = _compensationRequisitionService.GetCompensationRequisitionAcqPropertiesAtTime(id, time);
+
+ return new JsonResult(_mapper.Map>(acqCompReqProperties));
+ }
+
+ [HttpGet("lease/{id:long}/properties/historical")]
+ [HasPermission(Permissions.CompensationRequisitionView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [SwaggerOperation(Tags = new[] { "compensation-requisition" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetLeaseCompensationRequisitionPropertiesAtTime([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(CompensationRequisitionController),
+ nameof(GetLeaseCompensationRequisitionPropertiesAtTime),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var leaseCompReqProperties = _compensationRequisitionService.GetCompensationRequisitionLeasePropertiesAtTime(id, time);
+
+ return new JsonResult(_mapper.Map>(leaseCompReqProperties));
+ }
+
+ [HttpGet("{id:long}/acquisition-payees/historical")]
+ [HasPermission(Permissions.CompensationRequisitionView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(List), 200)]
+ [SwaggerOperation(Tags = new[] { "compensation-requisition" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetCompensationRequisitionAcquisitionPayees([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(CompensationRequisitionController),
+ nameof(GetCompensationRequisitionAcquisitionPayees),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var acquisitionPayees = _compensationRequisitionService.GetCompensationRequisitionAcquisitionPayeesAtTime(id, time);
+
+ return new JsonResult(_mapper.Map>(acquisitionPayees));
+ }
+
+ [HttpGet("{id:long}/lease-payees/historical")]
+ [HasPermission(Permissions.CompensationRequisitionView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(List), 200)]
+ [SwaggerOperation(Tags = new[] { "compensation-requisition" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetCompensationRequisitionLeasePayees([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(CompensationRequisitionController),
+ nameof(GetCompensationRequisitionLeasePayees),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var leasePayees = _compensationRequisitionService.GetCompensationRequisitionLeasePayeesAtTime(id, time);
+
+ return new JsonResult(_mapper.Map>(leasePayees));
+ }
}
}
diff --git a/source/backend/api/Areas/Contacts/Controllers/SearchController.cs b/source/backend/api/Areas/Contacts/Controllers/SearchController.cs
index 7c0a4a6407..1c062b6bd4 100644
--- a/source/backend/api/Areas/Contacts/Controllers/SearchController.cs
+++ b/source/backend/api/Areas/Contacts/Controllers/SearchController.cs
@@ -5,16 +5,15 @@
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Areas.Contact.Models.Search;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Models.Base;
using Pims.Api.Models.Concepts.Contact;
-using Pims.Core.Api.Policies;
using Pims.Api.Services.Interfaces;
-using Pims.Dal.Entities.Models;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
using Swashbuckle.AspNetCore.Annotations;
-using Pims.Core.Api.Exceptions;
namespace Pims.Api.Areas.Contact.Controllers
{
diff --git a/source/backend/api/Areas/Disposition/Controllers/DispositionFileController.cs b/source/backend/api/Areas/Disposition/Controllers/DispositionFileController.cs
index 19943fe016..eaf3ba473c 100644
--- a/source/backend/api/Areas/Disposition/Controllers/DispositionFileController.cs
+++ b/source/backend/api/Areas/Disposition/Controllers/DispositionFileController.cs
@@ -5,15 +5,15 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Models.Concepts.DispositionFile;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Exceptions;
using Pims.Core.Extensions;
using Pims.Core.Json;
-using Pims.Dal.Exceptions;
using Pims.Core.Security;
+using Pims.Dal.Exceptions;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Disposition.Controllers
@@ -389,7 +389,7 @@ public IActionResult AddDispositionFileSale([FromRoute] long id, [FromBody] Disp
[ProducesResponseType(typeof(DispositionFileSaleModel), 200)]
[SwaggerOperation(Tags = new[] { "dispositionfile" })]
[TypeFilter(typeof(NullJsonResultFilter))]
- public IActionResult UpdateDispositionFileSale([FromRoute]long id, [FromRoute]long saleId, [FromBody] DispositionFileSaleModel dispositionFileSale)
+ public IActionResult UpdateDispositionFileSale([FromRoute] long id, [FromRoute] long saleId, [FromBody] DispositionFileSaleModel dispositionFileSale)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
diff --git a/source/backend/api/Areas/Disposition/Controllers/SearchController.cs b/source/backend/api/Areas/Disposition/Controllers/SearchController.cs
index 6dd591c8ba..eeb95e62eb 100644
--- a/source/backend/api/Areas/Disposition/Controllers/SearchController.cs
+++ b/source/backend/api/Areas/Disposition/Controllers/SearchController.cs
@@ -6,16 +6,16 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Areas.Disposition.Models.Search;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Models.Base;
using Pims.Api.Models.Concepts.DispositionFile;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
-using Pims.Dal.Entities.Models;
using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Disposition.Controllers
diff --git a/source/backend/api/Areas/Documents/DocumentController.cs b/source/backend/api/Areas/Documents/DocumentController.cs
index 1b4a2563d2..2677563aee 100644
--- a/source/backend/api/Areas/Documents/DocumentController.cs
+++ b/source/backend/api/Areas/Documents/DocumentController.cs
@@ -281,7 +281,7 @@ public async Task GetDocumentMetadata(long mayanDocumentId)
public async Task GetDocumentFilePageList(long mayanDocumentId, long documentFileId)
{
var result = await _documentService.GetDocumentFilePageListAsync(mayanDocumentId, documentFileId);
- if(result.HttpStatusCode != System.Net.HttpStatusCode.OK)
+ if (result.HttpStatusCode != System.Net.HttpStatusCode.OK)
{
throw new HttpClientRequestException(result.Message, result.HttpStatusCode);
}
diff --git a/source/backend/api/Areas/Documents/DocumentRelationshipController.cs b/source/backend/api/Areas/Documents/DocumentRelationshipController.cs
index e0ca25a724..df9ce8a907 100644
--- a/source/backend/api/Areas/Documents/DocumentRelationshipController.cs
+++ b/source/backend/api/Areas/Documents/DocumentRelationshipController.cs
@@ -111,14 +111,22 @@ public IActionResult GetRelationshipDocuments(DocumentRelationType relationshipT
var projectDocuments = _documentFileService.GetFileDocuments(FileType.Project, long.Parse(parentId));
var mappedProjectDocuments = _mapper.Map>(projectDocuments);
return new JsonResult(mappedProjectDocuments);
- case DocumentRelationType.ManagementFiles:
- var managementDocuments = _documentFileService.GetFileDocuments(FileType.Management, long.Parse(parentId));
+ case DocumentRelationType.ManagementActivities:
+ var managementDocuments = _documentFileService.GetFileDocuments(FileType.ManagementActivity, long.Parse(parentId));
var mappedPropertyActivityDocuments = _mapper.Map>(managementDocuments);
return new JsonResult(mappedPropertyActivityDocuments);
+ case DocumentRelationType.ManagementFiles:
+ var managementFileDocuments = _documentFileService.GetFileDocuments(FileType.ManagementFile, long.Parse(parentId));
+ var mappedManagementFileDocuments = _mapper.Map>(managementFileDocuments);
+ return new JsonResult(mappedManagementFileDocuments);
case DocumentRelationType.DispositionFiles:
var dispositionFileDocuments = _documentFileService.GetFileDocuments(FileType.Disposition, long.Parse(parentId));
var mappedDispositionFileDocuments = _mapper.Map>(dispositionFileDocuments);
return new JsonResult(mappedDispositionFileDocuments);
+ case DocumentRelationType.Properties:
+ var propertyDocuments = _documentFileService.GetFileDocuments(FileType.Property, long.Parse(parentId));
+ var mappedPropertyFileDocuments = _mapper.Map>(propertyDocuments);
+ return new JsonResult(mappedPropertyFileDocuments);
default:
throw new BadRequestException("Relationship type not valid for retrieve.");
}
@@ -152,10 +160,14 @@ public async Task UploadDocumentWithParent(
await _documentFileService.UploadProjectDocument(long.Parse(parentId), uploadRequest); break;
case DocumentRelationType.Leases:
await _documentFileService.UploadLeaseDocument(long.Parse(parentId), uploadRequest); break;
- case DocumentRelationType.ManagementFiles:
+ case DocumentRelationType.ManagementActivities:
await _documentFileService.UploadPropertyActivityDocument(long.Parse(parentId), uploadRequest); break;
+ case DocumentRelationType.ManagementFiles:
+ await _documentFileService.UploadManagementFileDocument(long.Parse(parentId), uploadRequest); break;
case DocumentRelationType.DispositionFiles:
await _documentFileService.UploadDispositionDocument(long.Parse(parentId), uploadRequest); break;
+ case DocumentRelationType.Properties:
+ await _documentFileService.UploadPropertyDocument(long.Parse(parentId), uploadRequest); break;
case DocumentRelationType.Templates:
await _formDocumentService.UploadFormDocumentTemplateAsync(parentId, uploadRequest); break;
default:
@@ -177,7 +189,7 @@ public async Task UploadDocumentWithParent(
[ProducesResponseType(typeof(bool), 200)]
[SwaggerOperation(Tags = new[] { "document" })]
[TypeFilter(typeof(NullJsonResultFilter))]
- public async Task DeleteDocumentRelationship([FromRoute]DocumentRelationType relationshipType, [FromBody]DocumentRelationshipModel model)
+ public async Task DeleteDocumentRelationship([FromRoute] DocumentRelationType relationshipType, [FromBody] DocumentRelationshipModel model)
{
switch (relationshipType)
{
@@ -201,14 +213,22 @@ public async Task DeleteDocumentRelationship([FromRoute]DocumentR
var projectRelationship = _mapper.Map(model);
var projectResult = await _documentFileService.DeleteProjectDocumentAsync(projectRelationship);
return new JsonResult(projectResult);
- case DocumentRelationType.ManagementFiles:
+ case DocumentRelationType.ManagementActivities:
var propertyActivityRelationship = _mapper.Map(model);
var propertyActivityResult = await _documentFileService.DeletePropertyActivityDocumentAsync(propertyActivityRelationship);
return new JsonResult(propertyActivityResult);
+ case DocumentRelationType.ManagementFiles:
+ var managementRelationship = _mapper.Map(model);
+ var managementResult = await _documentFileService.DeleteManagementFileDocumentAsync(managementRelationship);
+ return new JsonResult(managementResult);
case DocumentRelationType.DispositionFiles:
var dispositionRelationship = _mapper.Map(model);
var dispositionResult = await _documentFileService.DeleteDispositionDocumentAsync(dispositionRelationship);
return new JsonResult(dispositionResult);
+ case DocumentRelationType.Properties:
+ var propertyRelationship = _mapper.Map(model);
+ var propertyResult = await _documentFileService.DeletePropertyDocumentAsync(propertyRelationship);
+ return new JsonResult(propertyResult);
default:
throw new BadRequestException("Relationship type not valid for delete.");
}
diff --git a/source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs b/source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs
index 92628121ad..5a18ca5ea7 100644
--- a/source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs
+++ b/source/backend/api/Areas/ExpropriationPayment/ExpropriationPaymentController.cs
@@ -3,10 +3,10 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Models.Concepts.ExpropriationPayment;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
diff --git a/source/backend/api/Areas/FinancialCodes/FinancialCodeController.cs b/source/backend/api/Areas/FinancialCodes/FinancialCodeController.cs
index 646fc902d5..736735f204 100644
--- a/source/backend/api/Areas/FinancialCodes/FinancialCodeController.cs
+++ b/source/backend/api/Areas/FinancialCodes/FinancialCodeController.cs
@@ -2,8 +2,8 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Models.Concepts.FinancialCode;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Json;
using Pims.Core.Security;
using Swashbuckle.AspNetCore.Annotations;
diff --git a/source/backend/api/Areas/FormDocument/FormDocumentController.cs b/source/backend/api/Areas/FormDocument/FormDocumentController.cs
index 736d35e464..2856f6f424 100644
--- a/source/backend/api/Areas/FormDocument/FormDocumentController.cs
+++ b/source/backend/api/Areas/FormDocument/FormDocumentController.cs
@@ -3,13 +3,13 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Constants;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Models.Concepts.FormDocument;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Json;
-using Pims.Dal.Entities;
using Pims.Core.Security;
+using Pims.Dal.Entities;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Controllers
diff --git a/source/backend/api/Areas/HistoricalNumber/HistoricalNumberController.cs b/source/backend/api/Areas/HistoricalNumber/HistoricalNumberController.cs
index c89d13eb60..2caa39f579 100644
--- a/source/backend/api/Areas/HistoricalNumber/HistoricalNumberController.cs
+++ b/source/backend/api/Areas/HistoricalNumber/HistoricalNumberController.cs
@@ -5,8 +5,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.Property;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Exceptions;
using Pims.Core.Extensions;
using Pims.Core.Json;
diff --git a/source/backend/api/Areas/Keycloak/Controllers/AccessRequestController.cs b/source/backend/api/Areas/Keycloak/Controllers/AccessRequestController.cs
index 609f0f5e17..997561ed37 100644
--- a/source/backend/api/Areas/Keycloak/Controllers/AccessRequestController.cs
+++ b/source/backend/api/Areas/Keycloak/Controllers/AccessRequestController.cs
@@ -4,8 +4,8 @@
using Pims.Api.Models.Concepts.AccessRequest;
using Pims.Core.Api.Policies;
using Pims.Core.Json;
-using Pims.Dal.Keycloak;
using Pims.Core.Security;
+using Pims.Dal.Keycloak;
using Swashbuckle.AspNetCore.Annotations;
using Entity = Pims.Dal.Entities;
diff --git a/source/backend/api/Areas/Keycloak/Controllers/UserController.cs b/source/backend/api/Areas/Keycloak/Controllers/UserController.cs
index 8712c8cd2f..3a83a4a1c6 100644
--- a/source/backend/api/Areas/Keycloak/Controllers/UserController.cs
+++ b/source/backend/api/Areas/Keycloak/Controllers/UserController.cs
@@ -5,8 +5,8 @@
using Pims.Api.Models.Concepts.User;
using Pims.Core.Api.Policies;
using Pims.Core.Json;
-using Pims.Dal.Keycloak;
using Pims.Core.Security;
+using Pims.Dal.Keycloak;
using Swashbuckle.AspNetCore.Annotations;
using Entity = Pims.Dal.Entities;
diff --git a/source/backend/api/Areas/Leases/Controllers/ConsultationController.cs b/source/backend/api/Areas/Leases/Controllers/ConsultationController.cs
index fa0b95d9af..7798756720 100644
--- a/source/backend/api/Areas/Leases/Controllers/ConsultationController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/ConsultationController.cs
@@ -1,14 +1,13 @@
-
using System;
using System.Collections.Generic;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
@@ -70,7 +69,6 @@ public IActionResult GetLeaseConsultations([FromRoute] long id)
User.GetUsername(),
DateTime.Now);
-
var consultation = _leaseService.GetConsultations(id);
return new JsonResult(_mapper.Map>(consultation));
}
diff --git a/source/backend/api/Areas/Leases/Controllers/InsuranceController.cs b/source/backend/api/Areas/Leases/Controllers/InsuranceController.cs
index c1112fbf27..61f16414fa 100644
--- a/source/backend/api/Areas/Leases/Controllers/InsuranceController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/InsuranceController.cs
@@ -6,12 +6,12 @@
using Microsoft.Extensions.Logging;
using Pims.Api.Areas.Lease.Controllers;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
-using Pims.Dal.Entities;
using Pims.Core.Security;
+using Pims.Dal.Entities;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Leases.Controllers
diff --git a/source/backend/api/Areas/Leases/Controllers/LeaseController.cs b/source/backend/api/Areas/Leases/Controllers/LeaseController.cs
index a4259881a5..d68e2c194f 100644
--- a/source/backend/api/Areas/Leases/Controllers/LeaseController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/LeaseController.cs
@@ -14,8 +14,8 @@
using Pims.Core.Json;
using Pims.Core.Security;
using Pims.Dal.Exceptions;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
-using Pims.Api.Models.Concepts.AcquisitionFile;
namespace Pims.Api.Areas.Lease.Controllers
{
@@ -32,6 +32,7 @@ public class LeaseController : ControllerBase
{
#region Variables
private readonly ILeaseService _leaseService;
+ private readonly ILeaseRepository _leaseRepository;
private readonly IMapper _mapper;
private readonly ILogger _logger;
#endregion
@@ -44,12 +45,13 @@ public class LeaseController : ControllerBase
///
///
///
- ///
- public LeaseController(ILeaseService leaseService, IMapper mapper, ILogger logger)
+ ///
+ public LeaseController(ILeaseService leaseService, IMapper mapper, ILogger logger, ILeaseRepository leaseRepository)
{
_mapper = mapper;
_leaseService = leaseService;
_logger = logger;
+ _leaseRepository = leaseRepository;
}
#endregion
@@ -234,6 +236,24 @@ public IActionResult GetAcquisitionTeamMembers()
return new JsonResult(_mapper.Map>(team));
}
+ [HttpGet("{id:long}/historical")]
+ [Produces("application/json")]
+ [HasPermission(Permissions.LeaseView)]
+ [ProducesResponseType(typeof(LeaseModel), 200)]
+ [SwaggerOperation(Tags = new[] { "lease" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetLeaseAtTime([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(LeaseController),
+ nameof(GetLeaseAtTime),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var pimsLease = _leaseRepository.GetLeaseAtTime(id, time);
+ return new JsonResult(_mapper.Map(pimsLease));
+ }
#endregion
}
}
diff --git a/source/backend/api/Areas/Leases/Controllers/LeasePaymentController.cs b/source/backend/api/Areas/Leases/Controllers/LeasePaymentController.cs
index b620fa8b28..fa27ee3740 100644
--- a/source/backend/api/Areas/Leases/Controllers/LeasePaymentController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/LeasePaymentController.cs
@@ -4,12 +4,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
-using Pims.Dal.Entities;
using Pims.Core.Security;
+using Pims.Dal.Entities;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Lease.Controllers
diff --git a/source/backend/api/Areas/Leases/Controllers/LeasePeriodController.cs b/source/backend/api/Areas/Leases/Controllers/LeasePeriodController.cs
index 10e875c328..ced34cb283 100644
--- a/source/backend/api/Areas/Leases/Controllers/LeasePeriodController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/LeasePeriodController.cs
@@ -5,12 +5,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
-using Pims.Dal.Entities;
using Pims.Core.Security;
+using Pims.Dal.Entities;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Lease.Controllers
diff --git a/source/backend/api/Areas/Leases/Controllers/LeaseRenewalController.cs b/source/backend/api/Areas/Leases/Controllers/LeaseRenewalController.cs
index e3cfd37d7c..927ec7e698 100644
--- a/source/backend/api/Areas/Leases/Controllers/LeaseRenewalController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/LeaseRenewalController.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using MapsterMapper;
@@ -6,8 +5,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
diff --git a/source/backend/api/Areas/Leases/Controllers/LeaseStakeholderController.cs b/source/backend/api/Areas/Leases/Controllers/LeaseStakeholderController.cs
index b7222976b7..669e742e67 100644
--- a/source/backend/api/Areas/Leases/Controllers/LeaseStakeholderController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/LeaseStakeholderController.cs
@@ -5,8 +5,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
diff --git a/source/backend/api/Areas/Leases/Controllers/PropertyImprovementController.cs b/source/backend/api/Areas/Leases/Controllers/PropertyImprovementController.cs
index f8f8d21525..eb1ae0650c 100644
--- a/source/backend/api/Areas/Leases/Controllers/PropertyImprovementController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/PropertyImprovementController.cs
@@ -5,8 +5,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
diff --git a/source/backend/api/Areas/Leases/Controllers/PropertyLeaseController.cs b/source/backend/api/Areas/Leases/Controllers/PropertyLeaseController.cs
index ee9f916bdf..5132bc71ec 100644
--- a/source/backend/api/Areas/Leases/Controllers/PropertyLeaseController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/PropertyLeaseController.cs
@@ -5,8 +5,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
diff --git a/source/backend/api/Areas/Leases/Controllers/SearchController.cs b/source/backend/api/Areas/Leases/Controllers/SearchController.cs
index 9ba979a98e..d359fa4006 100644
--- a/source/backend/api/Areas/Leases/Controllers/SearchController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/SearchController.cs
@@ -5,16 +5,16 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Areas.Lease.Models.Search;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Models.Base;
using Pims.Api.Models.Concepts.Lease;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
-using Pims.Dal.Entities.Models;
using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Lease.Controllers
diff --git a/source/backend/api/Areas/Leases/Controllers/SecurityDepositReturnController.cs b/source/backend/api/Areas/Leases/Controllers/SecurityDepositReturnController.cs
index ef066317ad..44f7f328fc 100644
--- a/source/backend/api/Areas/Leases/Controllers/SecurityDepositReturnController.cs
+++ b/source/backend/api/Areas/Leases/Controllers/SecurityDepositReturnController.cs
@@ -3,14 +3,14 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Models.Concepts.Deposit;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
-using Pims.Dal.Entities;
using Pims.Core.Security;
+using Pims.Dal.Entities;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Lease.Controllers
diff --git a/source/backend/api/Areas/Management/ActivitySearchController.cs b/source/backend/api/Areas/Management/ActivitySearchController.cs
new file mode 100644
index 0000000000..7acf3b0719
--- /dev/null
+++ b/source/backend/api/Areas/Management/ActivitySearchController.cs
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http.Extensions;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Pims.Api.Areas.Management.Models;
+using Pims.Api.Helpers.Extensions;
+using Pims.Api.Models.Base;
+using Pims.Api.Models.Concepts.Property;
+using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
+using Pims.Core.Json;
+using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
+using Swashbuckle.AspNetCore.Annotations;
+
+namespace Pims.Api.Areas.Management.Controllers
+{
+ ///
+ /// SearchController class, provides endpoints for searching management files.
+ ///
+ [Authorize]
+ [ApiController]
+ [ApiVersion("1.0")]
+ [Area("management-activities")]
+ [Route("v{version:apiVersion}/[area]/search")]
+ [Route("[area]/search")]
+ public class ActivitySearchController : ControllerBase
+ {
+ private readonly IManagementActivityService _managementActivityService;
+ private readonly IMapper _mapper;
+ private readonly ILogger _logger;
+
+ ///
+ /// Creates a new instance of a SearchController class, initializes it with the specified arguments.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public ActivitySearchController(IManagementActivityService managementActivityService, IMapper mapper, ILogger logger)
+ {
+ _managementActivityService = managementActivityService;
+ _mapper = mapper;
+ _logger = logger;
+ }
+
+ #region Management List View Endpoints
+
+ ///
+ /// Gets all the Management Files that satisfy the filter parameters.
+ ///
+ /// An array of Management Files matching the filter.
+ [HttpGet]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [ProducesResponseType(typeof(Api.Models.ErrorResponseModel), 400)]
+ [SwaggerOperation(Tags = new[] { "management-activities" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementActivities()
+ {
+ var uri = new Uri(Request.GetDisplayUrl());
+ var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query);
+ return GetManagementActivitiesPaged(new ManagementActivityFilterModel(query));
+ }
+
+ ///
+ /// Gets all the Management Files that satisfy the filter parameters.
+ ///
+ /// An array of Management Files matching the filter.
+ [HttpPost("filter")]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [ProducesResponseType(typeof(Api.Models.ErrorResponseModel), 400)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementActivitiesPaged([FromBody]ManagementActivityFilterModel filter)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ActivitySearchController),
+ nameof(GetManagementActivitiesPaged),
+ User.GetUsername(),
+ DateTime.Now);
+
+ filter.ThrowBadRequestIfNull($"The request must include a filter.");
+ if (!filter.IsValid())
+ {
+ throw new BadRequestException("Management Activities filter must contain valid values.");
+ }
+
+ _logger.LogInformation("Dispatching to service: {Service}", _managementActivityService.GetType());
+
+ var managementActivities = _managementActivityService.GetPage((ManagementActivityFilter)filter);
+
+ return new JsonResult(_mapper.Map>(managementActivities));
+ }
+
+ #endregion
+ }
+}
diff --git a/source/backend/api/Areas/Management/ManagementActivityController.cs b/source/backend/api/Areas/Management/ManagementActivityController.cs
new file mode 100644
index 0000000000..1db1f31a0b
--- /dev/null
+++ b/source/backend/api/Areas/Management/ManagementActivityController.cs
@@ -0,0 +1,74 @@
+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.Models.Concepts.Property;
+using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
+using Pims.Core.Json;
+using Pims.Core.Security;
+using Pims.Dal.Entities;
+using Swashbuckle.AspNetCore.Annotations;
+
+namespace Pims.Api.Areas.Management.Controllers
+{
+ ///
+ /// ManagementActivityController class, provides endpoints for interacting with management activities.
+ ///
+ [Authorize]
+ [ApiController]
+ [ApiVersion("1.0")]
+ [Area("management-activities")]
+ [Route("v{version:apiVersion}/[area]")]
+ [Route("[area]")]
+ public class ManagementActivityController : ControllerBase
+ {
+ #region Variables
+ private readonly IPropertyService _propertyService;
+ private readonly IMapper _mapper;
+ private readonly ILogger _logger;
+ #endregion
+
+ ///
+ /// Creates a new instance of a ManagementActivityController class, initializes it with the specified arguments.
+ ///
+ ///
+ ///
+ ///
+ public ManagementActivityController(IPropertyService propertyService, IMapper mapper, ILogger logger)
+ {
+ _propertyService = propertyService;
+ _mapper = mapper;
+ _logger = logger;
+ }
+
+ ///
+ /// Get the specified management activity.
+ ///
+ ///
+ [HttpGet("{managementActivityId:long}")]
+ [HasPermission(Permissions.ManagementView, Permissions.ActivityView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(PropertyActivityModel), 200)]
+ [SwaggerOperation(Tags = new[] { "property" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementActivity(long managementActivityId)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementActivityController),
+ nameof(GetManagementActivity),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var activity = _propertyService.GetActivity(managementActivityId);
+
+ return new JsonResult(_mapper.Map(activity));
+ }
+ }
+}
diff --git a/source/backend/api/Areas/Management/ManagementFileActivityController.cs b/source/backend/api/Areas/Management/ManagementFileActivityController.cs
new file mode 100644
index 0000000000..2fbbe55b8f
--- /dev/null
+++ b/source/backend/api/Areas/Management/ManagementFileActivityController.cs
@@ -0,0 +1,215 @@
+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.Models.Concepts.Property;
+using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
+using Pims.Core.Json;
+using Pims.Core.Security;
+using Pims.Dal.Entities;
+using Swashbuckle.AspNetCore.Annotations;
+
+namespace Pims.Api.Areas.Management.Controllers
+{
+ ///
+ /// ManagementFileActivityController class, provides endpoints for interacting with management file activities.
+ ///
+ [Authorize]
+ [ApiController]
+ [ApiVersion("1.0")]
+ [Area("managementfiles")]
+ [Route("v{version:apiVersion}/[area]")]
+ [Route("[area]")]
+ public class ManagementFileActivityController : ControllerBase
+ {
+ #region Variables
+ private readonly IPropertyService _propertyService;
+ private readonly IManagementFileService _managementFileService;
+ private readonly IMapper _mapper;
+ private readonly ILogger _logger;
+ #endregion
+
+ ///
+ /// Creates a new instance of a ManagementFileActivityController class, initializes it with the specified arguments.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public ManagementFileActivityController(IPropertyService propertyService, IMapper mapper, ILogger logger, IManagementFileService managementFileService)
+ {
+ _propertyService = propertyService;
+ _managementFileService = managementFileService;
+ _mapper = mapper;
+ _logger = logger;
+ }
+
+ ///
+ /// Create the specified management file activity.
+ ///
+ ///
+ [HttpPost("{managementFileId:long}/management-activities")]
+ [HasPermission(Permissions.ManagementAdd)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(PropertyActivityModel), 200)]
+ [SwaggerOperation(Tags = new[] { "property" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult CreateManagementActivity(long managementFileId, [FromBody] PropertyActivityModel activityModel)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementActivityController),
+ nameof(CreateManagementActivity),
+ User.GetUsername(),
+ DateTime.Now);
+
+ // Management file activities need to populate the managementFileId field.
+ if (!activityModel.ManagementFileId.HasValue || activityModel.ManagementFileId.Value != managementFileId)
+ {
+ throw new BadRequestException("Invalid management file id.");
+ }
+ var activityEntity = _mapper.Map(activityModel);
+ var createdActivity = _propertyService.CreateActivity(activityEntity);
+
+ return new JsonResult(_mapper.Map(createdActivity));
+ }
+
+ ///
+ /// Get the specified management file activity.
+ ///
+ ///
+ [HttpGet("{managementFileId:long}/management-activities/{propertyActivityId:long}")]
+ [HasPermission(Permissions.ManagementView, Permissions.ActivityView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(PropertyActivityModel), 200)]
+ [SwaggerOperation(Tags = new[] { "property" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementActivity(long managementFileId, long propertyActivityId)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementActivityController),
+ nameof(GetManagementActivity),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var activity = _propertyService.GetActivity(propertyActivityId);
+
+ if (activity.ManagementFileId != managementFileId)
+ {
+ throw new BadRequestException("Activity with the given id does not match the management file id");
+ }
+
+ return new JsonResult(_mapper.Map(activity));
+ }
+
+ ///
+ /// Get the specified management file's activities.
+ ///
+ ///
+ [HttpGet("{managementFileId:long}/management-activities")]
+ [HasPermission(Permissions.ManagementView, Permissions.ActivityView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(PropertyActivityModel), 200)]
+ [SwaggerOperation(Tags = new[] { "property" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementActivities(long managementFileId)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementActivityController),
+ nameof(GetManagementActivities),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var activities = _propertyService.GetFileActivities(managementFileId);
+
+ return new JsonResult(_mapper.Map>(activities));
+ }
+
+ ///
+ /// Update the specified management file activity.
+ ///
+ ///
+ [HttpPut("{managementFileId:long}/management-activities/{activityId}")]
+ [HasPermission(Permissions.ManagementEdit)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(PropertyActivityModel), 200)]
+ [SwaggerOperation(Tags = new[] { "property" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult UpdateManagementActivity(long managementFileId, long activityId, [FromBody] PropertyActivityModel activityModel)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementActivityController),
+ nameof(UpdateManagementActivity),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var propertyActivity = _mapper.Map(activityModel);
+ if (!propertyActivity.ManagementFileId.HasValue || propertyActivity.ManagementFileId != managementFileId || propertyActivity.Internal_Id != activityId)
+ {
+ throw new BadRequestException("Invalid activity identifiers.");
+ }
+
+ var updatedProperty = _propertyService.UpdateActivity(propertyActivity);
+
+ return new JsonResult(_mapper.Map(updatedProperty));
+ }
+
+ ///
+ /// Delete the specified management file activity.
+ ///
+ ///
+ [HttpDelete("{managementFileId:long}/management-activities/{propertyActivityId:long}")]
+ [HasPermission(Permissions.ManagementEdit, Permissions.ActivityEdit)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(PropertyActivityModel), 200)]
+ [SwaggerOperation(Tags = new[] { "property" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult DeleteManagementActivity(long managementFileId, long propertyActivityId)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementActivityController),
+ nameof(DeleteManagementActivity),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var deleted = _propertyService.DeleteFileActivity(managementFileId, propertyActivityId);
+
+ return new JsonResult(deleted);
+ }
+
+ ///
+ /// Get all of the activities related to an property on the specified management file.
+ ///
+ ///
+ [HttpGet("{managementFileId:long}/properties/management-activities")]
+ [HasPermission(Permissions.ManagementView, Permissions.ActivityView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(PropertyActivityModel), 200)]
+ [SwaggerOperation(Tags = new[] { "property" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementPropertyActivities(long managementFileId)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementActivityController),
+ nameof(GetManagementPropertyActivities),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var propertyIds = _managementFileService.GetProperties(managementFileId).Select(mp => mp.PropertyId);
+ var activities = _propertyService.GetActivitiesByPropertyIds(propertyIds);
+
+ return new JsonResult(_mapper.Map>(activities));
+ }
+ }
+}
diff --git a/source/backend/api/Areas/Management/ManagementFileController.cs b/source/backend/api/Areas/Management/ManagementFileController.cs
new file mode 100644
index 0000000000..5675cae40e
--- /dev/null
+++ b/source/backend/api/Areas/Management/ManagementFileController.cs
@@ -0,0 +1,227 @@
+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.Models.Concepts.ManagementFile;
+using Pims.Api.Models.Concepts.Property;
+using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
+using Pims.Core.Json;
+using Pims.Core.Security;
+using Pims.Dal.Entities;
+using Pims.Dal.Exceptions;
+using Swashbuckle.AspNetCore.Annotations;
+
+namespace Pims.Api.Areas.Management.Controllers
+{
+ ///
+ /// ManagementFileController class, provides endpoints for interacting with management files.
+ ///
+ [Authorize]
+ [ApiController]
+ [ApiVersion("1.0")]
+ [Area("managementfiles")]
+ [Route("v{version:apiVersion}/[area]")]
+ [Route("[area]")]
+ public class ManagementFileController : ControllerBase
+ {
+ #region Variables
+ private readonly IManagementFileService _managementService;
+ private readonly IMapper _mapper;
+ private readonly ILogger _logger;
+ private readonly IPropertyService _propertyService;
+
+ #endregion
+
+ #region Constructors
+
+ ///
+ /// Creates a new instance of a ManagementFileController class, initializes it with the specified arguments.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public ManagementFileController(IPropertyService propertyService, IManagementFileService managementService, IMapper mapper, ILogger logger)
+ {
+ _propertyService = propertyService;
+ _managementService = managementService;
+ _mapper = mapper;
+ _logger = logger;
+ }
+ #endregion
+
+ #region Endpoints
+
+ ///
+ /// Gets the specified management file.
+ ///
+ ///
+ [HttpGet("{id:long}")]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(ManagementFileModel), 200)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementFile(long id)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementFileController),
+ nameof(GetManagementFile),
+ User.GetUsername(),
+ DateTime.Now);
+
+ _logger.LogInformation("Dispatching to service: {Service}", _managementService.GetType());
+
+ var managementFile = _managementService.GetById(id);
+ return new JsonResult(_mapper.Map(managementFile));
+ }
+
+ ///
+ /// Creates a new Management File entity.
+ ///
+ ///
+ [HttpPost]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ [HasPermission(Permissions.ManagementAdd)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(ManagementFileModel), 200)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult AddManagementFile([FromBody] ManagementFileModel model, [FromQuery] string[] userOverrideCodes)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementFileController),
+ nameof(AddManagementFile),
+ User.GetUsername(),
+ DateTime.Now);
+
+ _logger.LogInformation("Dispatching to service: {Service}", _managementService.GetType());
+
+ var managementFileEntity = _mapper.Map(model);
+ var managementFile = _managementService.Add(managementFileEntity, userOverrideCodes.Select(oc => UserOverrideCode.Parse(oc)));
+
+ return new JsonResult(_mapper.Map(managementFile));
+ }
+
+ [HttpPut("{id:long}")]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ [HasPermission(Permissions.ManagementEdit)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(ManagementFileModel), 200)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult UpdateManagementFile([FromRoute] long id, [FromBody] ManagementFileModel model, [FromQuery] string[] userOverrideCodes)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementFileController),
+ nameof(UpdateManagementFile),
+ User.GetUsername(),
+ DateTime.Now);
+
+ _logger.LogInformation("Dispatching to service: {Service}", _managementService.GetType());
+
+ var managementFileEntity = _mapper.Map(model);
+ var managementFile = _managementService.Update(id, managementFileEntity, userOverrideCodes.Select(oc => UserOverrideCode.Parse(oc)));
+
+ return new JsonResult(_mapper.Map(managementFile));
+ }
+
+ ///
+ /// Gets the specified management file last updated-by information.
+ ///
+ ///
+ [HttpGet("{id:long}/updateInfo")]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(Dal.Entities.Models.LastUpdatedByModel), 200)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetLastUpdatedBy(long id)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementFileController),
+ nameof(GetLastUpdatedBy),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var lastUpdated = _managementService.GetLastUpdateInformation(id);
+ return new JsonResult(lastUpdated);
+ }
+
+ ///
+ /// Get the management file properties.
+ ///
+ ///
+ [HttpGet("{id:long}/properties")]
+ [HasPermission(Permissions.ManagementView, Permissions.PropertyView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementFileProperties(long id)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementFileController),
+ nameof(GetManagementFileProperties),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var managementfileProperties = _managementService.GetProperties(id);
+
+ return new JsonResult(_mapper.Map>(managementfileProperties));
+ }
+
+ ///
+ /// Get all unique persons and organizations that belong to at least one management file as a team member.
+ ///
+ ///
+ [HttpGet("team-members")]
+ [HasPermission(Permissions.ManagementView)]
+ [HasPermission(Permissions.ContactView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementTeamMembers()
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ManagementFileController),
+ nameof(GetManagementTeamMembers),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var team = _managementService.GetTeamMembers();
+
+ return new JsonResult(_mapper.Map>(team));
+ }
+
+ ///
+ /// Update the management file properties.
+ ///
+ ///
+ [HttpPut("{id:long}/properties")]
+ [HasPermission(Permissions.ManagementEdit)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(ManagementFileModel), 200)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ public IActionResult UpdateManagementFileProperties([FromBody] ManagementFileModel managementFileModel, [FromQuery] string[] userOverrideCodes)
+ {
+ var managementFileEntity = _mapper.Map(managementFileModel);
+ var managementFile = _managementService.UpdateProperties(managementFileEntity, userOverrideCodes.Select(oc => UserOverrideCode.Parse(oc)));
+ return new JsonResult(_mapper.Map(managementFile));
+ }
+ #endregion
+ }
+}
diff --git a/source/backend/api/Areas/Management/Models/ManagementActivityFilterModel.cs b/source/backend/api/Areas/Management/Models/ManagementActivityFilterModel.cs
new file mode 100644
index 0000000000..127bdadde6
--- /dev/null
+++ b/source/backend/api/Areas/Management/Models/ManagementActivityFilterModel.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using Pims.Core.Extensions;
+using Pims.Dal.Entities.Models;
+
+namespace Pims.Api.Areas.Management.Models
+{
+ public class ManagementActivityFilterModel : PageFilter
+ {
+ ///
+ /// get/set - The pid identifier to search by.
+ ///
+ public string Pid { get; set; }
+
+ ///
+ /// get/set - The pin identifier to search by.
+ ///
+ public string Pin { get; set; }
+
+ ///
+ /// get/set - The address to search by.
+ ///
+ public string Address { get; set; }
+
+ ///
+ /// get/set - The management file name or the file number or the legacy reference number, search for all simultaneously.
+ ///
+ public string FileNameOrNumberOrReference { get; set; }
+
+ ///
+ /// get/set - The Activity Type.
+ ///
+ public string ActivityTypeCode { get; set; }
+
+ ///
+ /// get/set - The Activity Status Code.
+ ///
+ public string ActivityStatusCode { get; set; }
+
+ ///
+ /// get/set - The MOTI project name or the project number, search for both simultaneously.
+ ///
+ public string ProjectNameOrNumber { get; set; }
+
+ public ManagementActivityFilterModel()
+ {
+ }
+
+ public ManagementActivityFilterModel(Dictionary query)
+ : base(query)
+ {
+ var filter = new Dictionary(query, StringComparer.OrdinalIgnoreCase);
+
+ Pid = filter.GetStringValue(nameof(Pid));
+ Pin = filter.GetStringValue(nameof(Pin));
+ Address = filter.GetStringValue(nameof(Address));
+ FileNameOrNumberOrReference = filter.GetStringValue(nameof(FileNameOrNumberOrReference));
+ ActivityTypeCode = filter.GetStringValue(nameof(ActivityTypeCode));
+ ActivityStatusCode = filter.GetStringValue(nameof(ActivityStatusCode));
+ ProjectNameOrNumber = filter.GetStringValue(nameof(ProjectNameOrNumber));
+ }
+
+ ///
+ /// Convert to a ManagementActivityFilter.
+ ///
+ ///
+ public static explicit operator ManagementActivityFilter(ManagementActivityFilterModel model)
+ {
+ var filter = new ManagementActivityFilter
+ {
+ Page = model.Page,
+ Quantity = model.Quantity,
+
+ Pid = model.Pid,
+ Pin = model.Pin,
+ Address = model.Address,
+ FileNameOrNumberOrReference = model.FileNameOrNumberOrReference,
+ ActivityTypeCode = model.ActivityTypeCode,
+ ActivityStatusCode = model.ActivityStatusCode,
+ ProjectNameOrNumber = model.ProjectNameOrNumber,
+
+ Sort = model.Sort,
+ };
+
+ return filter;
+ }
+ }
+}
diff --git a/source/backend/api/Areas/Management/Models/ManagementFilterModel.cs b/source/backend/api/Areas/Management/Models/ManagementFilterModel.cs
new file mode 100644
index 0000000000..a32f3cf682
--- /dev/null
+++ b/source/backend/api/Areas/Management/Models/ManagementFilterModel.cs
@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using Pims.Core.Extensions;
+using Pims.Dal.Entities.Models;
+
+namespace Pims.Api.Areas.Management.Models.Search
+{
+ public class ManagementFilterModel : PageFilter
+ {
+ #region Properties
+
+ ///
+ /// get/set - The pid identifier to search by.
+ ///
+ public string Pid { get; set; }
+
+ ///
+ /// get/set - The pin identifier to search by.
+ ///
+ public string Pin { get; set; }
+
+ ///
+ /// get/set - The address to search by.
+ ///
+ public string Address { get; set; }
+
+ ///
+ /// get/set - The management file name or the file number or the legacy reference number, search for all simultaneously.
+ ///
+ public string FileNameOrNumberOrReference { get; set; }
+
+ ///
+ /// get/set - The status of the management file.
+ ///
+ public string ManagementFileStatusCode { get; set; }
+
+ ///
+ /// get/set - The status of the management file.
+ ///
+ public string ManagementFilePurposeCode { get; set; }
+
+ ///
+ /// get/set - The MOTI project name or the project number, search for both simultaneously.
+ ///
+ public string ProjectNameOrNumber { get; set; }
+
+ ///
+ /// get/set - The MOTI person id to search by for management team members.
+ ///
+ public long? TeamMemberPersonId { get; set; }
+
+ ///
+ /// get/set - The MOTI Organization id to search by for management team members.
+ ///
+ public long? TeamMemberOrganizationId { get; set; }
+ #endregion
+
+ #region Constructors
+
+ ///
+ /// Creates a new instance of a ManagementFilterModel class.
+ ///
+ public ManagementFilterModel()
+ {
+ }
+
+ ///
+ /// Creates a new instance of a ManagementFilterModel class, initializes with the specified arguments.
+ ///
+ ///
+ public ManagementFilterModel(Dictionary query)
+ : base(query)
+ {
+ // We want case-insensitive query parameter properties.
+ var filter = new Dictionary(query, StringComparer.OrdinalIgnoreCase);
+
+ this.Pid = filter.GetStringValue(nameof(this.Pid));
+ this.Pin = filter.GetStringValue(nameof(this.Pin));
+ this.Address = filter.GetStringValue(nameof(this.Address));
+ this.FileNameOrNumberOrReference = filter.GetStringValue(nameof(this.FileNameOrNumberOrReference));
+ this.ManagementFileStatusCode = filter.GetStringValue(nameof(this.ManagementFileStatusCode));
+ this.ProjectNameOrNumber = filter.GetStringValue(nameof(this.ProjectNameOrNumber));
+ this.ManagementFilePurposeCode = filter.GetStringValue(nameof(this.ManagementFilePurposeCode));
+ this.TeamMemberPersonId = filter.GetLongNullValue(nameof(this.TeamMemberPersonId));
+ this.TeamMemberOrganizationId = filter.GetLongNullValue(nameof(this.TeamMemberOrganizationId));
+
+ this.Sort = filter.GetStringArrayValue(nameof(this.Sort));
+ }
+ #endregion
+
+ #region Methods
+
+ ///
+ /// Convert to a ManagementFilter.
+ ///
+ ///
+ public static explicit operator ManagementFilter(ManagementFilterModel model)
+ {
+ var filter = new ManagementFilter
+ {
+ Page = model.Page,
+ Quantity = model.Quantity,
+
+ Pid = model.Pid,
+ Pin = model.Pin,
+ Address = model.Address,
+ FileNameOrNumberOrReference = model.FileNameOrNumberOrReference,
+ ManagementFileStatusCode = model.ManagementFileStatusCode,
+ ProjectNameOrNumber = model.ProjectNameOrNumber,
+ ManagementFilePurposeCode = model.ManagementFilePurposeCode,
+ TeamMemberPersonId = model.TeamMemberPersonId,
+ TeamMemberOrganizationId = model.TeamMemberOrganizationId,
+
+ Sort = model.Sort,
+ };
+
+ return filter;
+ }
+
+ ///
+ /// Determine if a valid filter was provided.
+ ///
+ /// true if the filter is valid, false otherwise.
+ public override bool IsValid()
+ {
+ return base.IsValid();
+ }
+ #endregion
+ }
+}
diff --git a/source/backend/api/Areas/Management/SearchController.cs b/source/backend/api/Areas/Management/SearchController.cs
new file mode 100644
index 0000000000..26cf330fe2
--- /dev/null
+++ b/source/backend/api/Areas/Management/SearchController.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http.Extensions;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Pims.Api.Areas.Management.Models.Search;
+using Pims.Api.Helpers.Extensions;
+using Pims.Api.Models.Base;
+using Pims.Api.Models.Concepts.ManagementFile;
+using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
+using Pims.Core.Json;
+using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
+using Swashbuckle.AspNetCore.Annotations;
+
+namespace Pims.Api.Areas.Management.Controllers
+{
+ ///
+ /// SearchController class, provides endpoints for searching management files.
+ ///
+ [Authorize]
+ [ApiController]
+ [ApiVersion("1.0")]
+ [Area("managementfiles")]
+ [Route("v{version:apiVersion}/[area]/search")]
+ [Route("[area]/search")]
+ public class SearchController : ControllerBase
+ {
+ #region Variables
+ private readonly IManagementFileService _managementService;
+ private readonly IMapper _mapper;
+ private readonly ILogger _logger;
+ #endregion
+
+ #region Constructors
+
+ ///
+ /// Creates a new instance of a SearchController class, initializes it with the specified arguments.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public SearchController(IManagementFileService managementService, IMapper mapper, ILogger logger)
+ {
+ _managementService = managementService;
+ _mapper = mapper;
+ _logger = logger;
+ }
+ #endregion
+
+ #region Management List View Endpoints
+
+ ///
+ /// Gets all the Management Files that satisfy the filter parameters.
+ ///
+ /// An array of Management Files matching the filter.
+ [HttpGet]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [ProducesResponseType(typeof(Api.Models.ErrorResponseModel), 400)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementFiles()
+ {
+ var uri = new Uri(Request.GetDisplayUrl());
+ var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query);
+ return GetManagementFiles(new ManagementFilterModel(query));
+ }
+
+ ///
+ /// Gets all the Management Files that satisfy the filter parameters.
+ ///
+ /// An array of Management Files matching the filter.
+ [HttpPost("filter")]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces("application/json")]
+ [ProducesResponseType(typeof(IEnumerable), 200)]
+ [ProducesResponseType(typeof(Api.Models.ErrorResponseModel), 400)]
+ [SwaggerOperation(Tags = new[] { "managementfile" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetManagementFiles([FromBody] ManagementFilterModel filter)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(SearchController),
+ nameof(GetManagementFiles),
+ User.GetUsername(),
+ DateTime.Now);
+
+ filter.ThrowBadRequestIfNull($"The request must include a filter.");
+ if (!filter.IsValid())
+ {
+ throw new BadRequestException("Management filter must contain valid values.");
+ }
+
+ _logger.LogInformation("Dispatching to service: {Service}", _managementService.GetType());
+
+ var managementFiles = _managementService.GetPage((ManagementFilter)filter);
+ return new JsonResult(_mapper.Map>(managementFiles));
+ }
+
+ #endregion
+ }
+}
diff --git a/source/backend/api/Areas/Notes/Controllers/NoteController.cs b/source/backend/api/Areas/Notes/Controllers/NoteController.cs
index 64736d84e8..e41b3aa241 100644
--- a/source/backend/api/Areas/Notes/Controllers/NoteController.cs
+++ b/source/backend/api/Areas/Notes/Controllers/NoteController.cs
@@ -1,13 +1,18 @@
+using System;
using System.Collections.Generic;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
using Pims.Api.Constants;
using Pims.Api.Models.Concepts.Note;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
+using Pims.Dal.Entities;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Notes.Controllers
@@ -26,6 +31,7 @@ public class NoteController : ControllerBase
#region Variables
private readonly INoteService _noteService;
private readonly IMapper _mapper;
+ private readonly ILogger _logger;
#endregion
#region Constructors
@@ -35,11 +41,13 @@ public class NoteController : ControllerBase
///
///
///
+ ///
///
- public NoteController(INoteService noteService, IMapper mapper)
+ public NoteController(INoteService noteService, IMapper mapper, ILogger logger)
{
_noteService = noteService;
_mapper = mapper;
+ _logger = logger;
}
#endregion
@@ -49,7 +57,7 @@ public NoteController(INoteService noteService, IMapper mapper)
/// Add the specified note.
///
/// The parent entity type.
- /// The note to add.
+ /// The note to add.
///
[HttpPost("{type}")]
[HasPermission(Permissions.NoteAdd)]
@@ -57,10 +65,48 @@ public NoteController(INoteService noteService, IMapper mapper)
[ProducesResponseType(typeof(EntityNoteModel), 200)]
[SwaggerOperation(Tags = new[] { "note" })]
[TypeFilter(typeof(NullJsonResultFilter))]
- public IActionResult AddNote(NoteType type, [FromBody] EntityNoteModel noteModel)
+ public IActionResult AddNote(NoteType type, [FromBody] EntityNoteModel model)
{
- var createdNote = _noteService.Add(type, noteModel);
- return new JsonResult(createdNote);
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(NoteController),
+ nameof(AddNote),
+ User.GetUsername(),
+ DateTime.Now);
+
+ switch (type)
+ {
+ case NoteType.Acquisition_File:
+ var acquisitionFileNoteEntity = _mapper.Map(model);
+ var acquisitionFileNote = _noteService.AddAcquisitionFileNote(acquisitionFileNoteEntity);
+ return new JsonResult(_mapper.Map(acquisitionFileNote));
+ case NoteType.Disposition_File:
+ var dispositionFileNoteEntity = _mapper.Map(model);
+ var dispositionFileNote = _noteService.AddDispositionFileNote(dispositionFileNoteEntity);
+ return new JsonResult(_mapper.Map(dispositionFileNote));
+ case NoteType.Lease_File:
+ var leaseNoteEntity = _mapper.Map(model);
+ var leaseNote = _noteService.AddLeaseNote(leaseNoteEntity);
+ return new JsonResult(_mapper.Map(leaseNote));
+ case NoteType.Project:
+ var projectNoteEntity = _mapper.Map(model);
+ var projectNote = _noteService.AddProjectNote(projectNoteEntity);
+ return new JsonResult(_mapper.Map(projectNote));
+ case NoteType.Research_File:
+ var researchFileNoteEntity = _mapper.Map(model);
+ var researchFileNote = _noteService.AddResearchFileNote(researchFileNoteEntity);
+ return new JsonResult(_mapper.Map(researchFileNote));
+ case NoteType.Management_File:
+ var managementFileNoteEntity = _mapper.Map(model);
+ var managementFileNote = _noteService.AddManagementFileNote(managementFileNoteEntity);
+ return new JsonResult(_mapper.Map(managementFileNote));
+ case NoteType.Property:
+ var propertyNoteEntity = _mapper.Map(model);
+ var propertyNote = _noteService.AddPropertyNote(propertyNoteEntity);
+ return new JsonResult(_mapper.Map(propertyNote));
+ default:
+ throw new BadRequestException("Relationship type not valid.");
+ }
}
///
@@ -77,8 +123,15 @@ public IActionResult AddNote(NoteType type, [FromBody] EntityNoteModel noteModel
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult GetNotes(NoteType type, long entityId)
{
- var notes = _noteService.GetNotes(type, entityId);
- var mappedNotes = _mapper.Map>(notes);
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(NoteController),
+ nameof(GetNotes),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var pimsNotes = _noteService.GetNotes(type, entityId);
+ var mappedNotes = _mapper.Map>(pimsNotes);
return new JsonResult(mappedNotes);
}
@@ -95,8 +148,15 @@ public IActionResult GetNotes(NoteType type, long entityId)
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult GetNoteById(long noteId)
{
- var note = _noteService.GetById(noteId);
- return new JsonResult(note);
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(NoteController),
+ nameof(GetNoteById),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var pimsNote = _noteService.GetById(noteId);
+ return new JsonResult(_mapper.Map(pimsNote));
}
///
@@ -113,12 +173,20 @@ public IActionResult GetNoteById(long noteId)
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult UpdateNote(long noteId, [FromBody] NoteModel noteModel)
{
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(NoteController),
+ nameof(UpdateNote),
+ User.GetUsername(),
+ DateTime.Now);
+
if (noteId != noteModel.Id)
{
return BadRequest("Model and path id do not match.");
}
- var updatedNote = _noteService.Update(noteModel);
- return new JsonResult(updatedNote);
+ var noteEntity = _mapper.Map(noteModel);
+ var updatedNote = _noteService.Update(noteEntity);
+ return new JsonResult(_mapper.Map(updatedNote));
}
///
@@ -135,6 +203,13 @@ public IActionResult UpdateNote(long noteId, [FromBody] NoteModel noteModel)
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult DeleteNote(NoteType type, long noteId)
{
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(NoteController),
+ nameof(DeleteNote),
+ User.GetUsername(),
+ DateTime.Now);
+
return new JsonResult(_noteService.DeleteNote(type, noteId));
}
#endregion
diff --git a/source/backend/api/Areas/Organizations/Controllers/OrganizationController.cs b/source/backend/api/Areas/Organizations/Controllers/OrganizationController.cs
index 63b1fe72a5..933c6ad312 100644
--- a/source/backend/api/Areas/Organizations/Controllers/OrganizationController.cs
+++ b/source/backend/api/Areas/Organizations/Controllers/OrganizationController.cs
@@ -3,12 +3,12 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Models.Concepts.Organization;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Exceptions;
using Pims.Core.Json;
-using Pims.Dal.Repositories;
using Pims.Core.Security;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Organizations.Controllers
diff --git a/source/backend/api/Areas/Persons/Controllers/PersonController.cs b/source/backend/api/Areas/Persons/Controllers/PersonController.cs
index e3927baf4f..ab4a09f5ec 100644
--- a/source/backend/api/Areas/Persons/Controllers/PersonController.cs
+++ b/source/backend/api/Areas/Persons/Controllers/PersonController.cs
@@ -3,12 +3,12 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Models.Concepts.Person;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Exceptions;
using Pims.Core.Json;
-using Pims.Dal.Repositories;
using Pims.Core.Security;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Persons.Controllers
diff --git a/source/backend/api/Areas/Products/Controllers/ProductController.cs b/source/backend/api/Areas/Products/Controllers/ProductController.cs
index 7120d8f17e..df81c29e27 100644
--- a/source/backend/api/Areas/Products/Controllers/ProductController.cs
+++ b/source/backend/api/Areas/Products/Controllers/ProductController.cs
@@ -1,12 +1,17 @@
+using System;
using System.Collections.Generic;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
using Pims.Api.Models.Concepts.AcquisitionFile;
-using Pims.Core.Api.Policies;
+using Pims.Api.Models.Concepts.Product;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Projects.Controllers
@@ -24,19 +29,25 @@ public class ProductController : ControllerBase
{
#region fields
private readonly IProjectService _projectService;
+ private readonly IProductRepository _productRepository;
private readonly IMapper _mapper;
+ private readonly ILogger _logger;
#endregion
///
/// Creates a new instance of a ProductController class, initializes it with the specified arguments.
///
///
+ ///
///
+ ///
///
- public ProductController(IProjectService projectService, IMapper mapper)
+ public ProductController(IProjectService projectService, IProductRepository productRepository, IMapper mapper, ILogger logger)
{
_projectService = projectService;
+ _productRepository = productRepository;
_mapper = mapper;
+ _logger = logger;
}
///
@@ -57,5 +68,24 @@ public IActionResult GetFiles(long productId)
return new JsonResult(_mapper.Map>(acquisitionFiles));
}
+
+ [HttpGet("{id:long}/historical")]
+ [Produces("application/json")]
+ [HasPermission(Permissions.ProjectView)]
+ [ProducesResponseType(typeof(ProductModel), 200)]
+ [SwaggerOperation(Tags = new[] { "product" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetProductAtTime([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ProductController),
+ nameof(GetProductAtTime),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var pimsProduct = _productRepository.GetProductAtTime(id, time);
+ return new JsonResult(_mapper.Map(pimsProduct));
+ }
}
}
diff --git a/source/backend/api/Areas/Projects/Controllers/ProjectController.cs b/source/backend/api/Areas/Projects/Controllers/ProjectController.cs
index 9a600d73cc..f5dc7ccfd0 100644
--- a/source/backend/api/Areas/Projects/Controllers/ProjectController.cs
+++ b/source/backend/api/Areas/Projects/Controllers/ProjectController.cs
@@ -1,17 +1,21 @@
+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.Models.Concepts.Product;
using Pims.Api.Models.Concepts.Project;
using Pims.Api.Services;
using Pims.Core.Api.Exceptions;
using Pims.Core.Api.Policies;
using Pims.Core.Exceptions;
+using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
using Pims.Dal.Exceptions;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Projects.Controllers
@@ -30,18 +34,23 @@ public class ProjectController : ControllerBase
#region fields
private readonly IProjectService _projectService;
private readonly IMapper _mapper;
+ private readonly IProjectRepository _projectRepository;
+ private readonly ILogger _logger;
#endregion
///
/// Creates a new instance of a ProjectController class, initializes it with the specified arguments.
///
///
+ ///
///
- ///
- public ProjectController(IProjectService projectService, IMapper mapper)
+ ///
+ public ProjectController(IProjectService projectService, IProjectRepository projectRepository, IMapper mapper, ILogger logger)
{
_projectService = projectService;
+ _projectRepository = projectRepository;
_mapper = mapper;
+ _logger = logger;
}
///
@@ -176,5 +185,24 @@ public IActionResult GetProducts(long projectId)
return new JsonResult(_mapper.Map>(products));
}
+
+ [HttpGet("{id:long}/historical")]
+ [Produces("application/json")]
+ [HasPermission(Permissions.ProjectView)]
+ [ProducesResponseType(typeof(ProjectModel), 200)]
+ [SwaggerOperation(Tags = new[] { "project" })]
+ [TypeFilter(typeof(NullJsonResultFilter))]
+ public IActionResult GetProjectAtTime([FromRoute] long id, [FromQuery] DateTime time)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ProductController),
+ nameof(GetProjectAtTime),
+ User.GetUsername(),
+ DateTime.Now);
+
+ var pimsProject = _projectRepository.GetProjectAtTime(id, time);
+ return new JsonResult(_mapper.Map(pimsProject));
+ }
}
}
diff --git a/source/backend/api/Areas/Projects/Controllers/SearchController.cs b/source/backend/api/Areas/Projects/Controllers/SearchController.cs
index 8be2fac94a..d30db4e536 100644
--- a/source/backend/api/Areas/Projects/Controllers/SearchController.cs
+++ b/source/backend/api/Areas/Projects/Controllers/SearchController.cs
@@ -6,11 +6,11 @@
using Pims.Api.Areas.Projects.Models;
using Pims.Api.Models.Base;
using Pims.Api.Models.Concepts.Project;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Json;
-using Pims.Dal.Entities.Models;
using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Projects.Controllers
diff --git a/source/backend/api/Areas/Property/Controllers/PropertyActivityController.cs b/source/backend/api/Areas/Property/Controllers/PropertyActivityController.cs
index 37909e8bcc..f771d48735 100644
--- a/source/backend/api/Areas/Property/Controllers/PropertyActivityController.cs
+++ b/source/backend/api/Areas/Property/Controllers/PropertyActivityController.cs
@@ -1,15 +1,16 @@
using System.Collections.Generic;
+using System.Linq;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Models.Concepts.Property;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Json;
+using Pims.Core.Security;
using Pims.Dal.Entities;
using Pims.Dal.Repositories;
-using Pims.Core.Security;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Property.Controllers
@@ -50,22 +51,6 @@ public PropertyActivityController(IPropertyService propertyService, ILookupRepos
#region Endpoints
- ///
- /// Get the activity subtypes.
- ///
- ///
- [HttpGet("management-activities/subtypes")]
- [HasPermission(Permissions.ManagementView)]
- [Produces("application/json")]
- [ProducesResponseType(typeof(List), 200)]
- [SwaggerOperation(Tags = new[] { "property" })]
- [TypeFilter(typeof(NullJsonResultFilter))]
- public IActionResult GetPropertyActivitySubtypes()
- {
- var subTypes = _lookupRepository.GetAllPropMgmtActivitySubtypes();
- return new JsonResult(_mapper.Map>(subTypes));
- }
-
///
/// Get the property management activities for the property with 'propertyId'.
///
@@ -94,8 +79,14 @@ public IActionResult GetPropertyActivities(long propertyId)
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult GetPropertyActivity(long propertyId, long activityId)
{
- var activity = _propertyService.GetActivity(propertyId, activityId);
- return new JsonResult(_mapper.Map(activity));
+ var propertyActivity = _propertyService.GetActivity(activityId);
+
+ if (propertyActivity.PimsPropPropActivities.Any(x => x.PropertyId == propertyId))
+ {
+ return new JsonResult(_mapper.Map(propertyActivity));
+ }
+
+ throw new BadRequestException("Activity with the given id does not match the property id");
}
///
@@ -132,8 +123,14 @@ public IActionResult CreatePropertyActivity(long propertyId, [FromBody] Property
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult UpdatePropertyActivity(long propertyId, long activityId, [FromBody] PropertyActivityModel activityModel)
{
- var activityEntity = _mapper.Map(activityModel);
- var updatedProperty = _propertyService.UpdateActivity(propertyId, activityId, activityEntity);
+ var propertyActivity = _mapper.Map(activityModel);
+ if (!propertyActivity.PimsPropPropActivities.Any(x => x.PropertyId == propertyId && x.PimsPropertyActivityId == activityId)
+ || propertyActivity.PimsPropertyActivityId != activityId)
+ {
+ throw new BadRequestException("Invalid activity identifiers.");
+ }
+
+ var updatedProperty = _propertyService.UpdateActivity(propertyActivity);
return new JsonResult(_mapper.Map(updatedProperty));
}
diff --git a/source/backend/api/Areas/Property/Controllers/PropertyContactController.cs b/source/backend/api/Areas/Property/Controllers/PropertyContactController.cs
index 7f61e57a04..906fb1b81e 100644
--- a/source/backend/api/Areas/Property/Controllers/PropertyContactController.cs
+++ b/source/backend/api/Areas/Property/Controllers/PropertyContactController.cs
@@ -2,13 +2,13 @@
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Models.Concepts.Property;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Json;
-using Pims.Dal.Entities;
using Pims.Core.Security;
+using Pims.Dal.Entities;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Property.Controllers
diff --git a/source/backend/api/Areas/Property/Controllers/PropertyOperationController.cs b/source/backend/api/Areas/Property/Controllers/PropertyOperationController.cs
index fe4796efd6..2324dd3a96 100644
--- a/source/backend/api/Areas/Property/Controllers/PropertyOperationController.cs
+++ b/source/backend/api/Areas/Property/Controllers/PropertyOperationController.cs
@@ -1,11 +1,10 @@
-
using System.Collections.Generic;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Models.Concepts.PropertyOperation;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Json;
using Pims.Core.Security;
using Swashbuckle.AspNetCore.Annotations;
@@ -43,8 +42,9 @@ public PropertyOperationController(IPropertyOperationService propertyOperationSe
#endregion
#region Endpoints
+
///
- /// Get the property operations related to a given property
+ /// Get the property operations related to a given property.
///
///
[HttpGet("{propertyId}/propertyOperations")]
diff --git a/source/backend/api/Areas/Property/Controllers/SearchController.cs b/source/backend/api/Areas/Property/Controllers/SearchController.cs
index 0699b1c23d..39ce15025a 100644
--- a/source/backend/api/Areas/Property/Controllers/SearchController.cs
+++ b/source/backend/api/Areas/Property/Controllers/SearchController.cs
@@ -5,14 +5,14 @@
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Areas.Property.Models.Search;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Models.Base;
using Pims.Api.Models.Concepts.Property;
+using Pims.Core.Api.Exceptions;
using Pims.Core.Api.Policies;
+using Pims.Core.Security;
using Pims.Dal.Entities.Models;
using Pims.Dal.Repositories;
-using Pims.Core.Security;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Property.Controllers
diff --git a/source/backend/api/Areas/PropertyOperation/Controllers/PropertyOperationController.cs b/source/backend/api/Areas/PropertyOperation/Controllers/PropertyOperationController.cs
index a6f4159d95..3ac011fc23 100644
--- a/source/backend/api/Areas/PropertyOperation/Controllers/PropertyOperationController.cs
+++ b/source/backend/api/Areas/PropertyOperation/Controllers/PropertyOperationController.cs
@@ -7,8 +7,8 @@
using Microsoft.Extensions.Logging;
using Pims.Api.Models.CodeTypes;
using Pims.Api.Models.Concepts.PropertyOperation;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Core.Security;
@@ -76,7 +76,7 @@ public IActionResult RunPropertyOperations([FromBody] IEnumerable>(operations);
- if(!Enum.TryParse(operationTypeCode?.Id, out PropertyOperationTypes propertyOperationTypes))
+ if (!Enum.TryParse(operationTypeCode?.Id, out PropertyOperationTypes propertyOperationTypes))
{
return BadRequest("Unsupported property operation type code.");
}
diff --git a/source/backend/api/Areas/Reports/Controllers/AcquisitionController.cs b/source/backend/api/Areas/Reports/Controllers/AcquisitionController.cs
index 4bd9eb441f..b0d4c439c8 100644
--- a/source/backend/api/Areas/Reports/Controllers/AcquisitionController.cs
+++ b/source/backend/api/Areas/Reports/Controllers/AcquisitionController.cs
@@ -8,14 +8,14 @@
using Pims.Api.Areas.Reports.Models.Acquisition;
using Pims.Api.Areas.Reports.Models.Agreement;
using Pims.Api.Helpers.Constants;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Helpers.Reporting;
-using Pims.Core.Api.Policies;
using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
using Pims.Core.Extensions;
-using Pims.Dal.Entities.Models;
using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
using Swashbuckle.AspNetCore.Annotations;
namespace Pims.Api.Areas.Reports.Controllers
diff --git a/source/backend/api/Areas/Reports/Controllers/ManagementActivityController.cs b/source/backend/api/Areas/Reports/Controllers/ManagementActivityController.cs
new file mode 100644
index 0000000000..9436b3b6f1
--- /dev/null
+++ b/source/backend/api/Areas/Reports/Controllers/ManagementActivityController.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http.Extensions;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Pims.Api.Areas.Management.Controllers;
+using Pims.Api.Areas.Management.Models;
+using Pims.Api.Areas.Reports.Models.Management;
+using Pims.Api.Helpers.Constants;
+using Pims.Api.Helpers.Extensions;
+using Pims.Api.Helpers.Reporting;
+using Pims.Api.Services;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Api.Policies;
+using Pims.Core.Extensions;
+using Pims.Core.Security;
+using Pims.Dal.Entities.Models;
+using Swashbuckle.AspNetCore.Annotations;
+
+namespace Pims.Api.Areas.Reports.Controllers
+{
+ ///
+ /// ManagementActivityController class, provides endpoints for generating reports.
+ ///
+ [Authorize]
+ [ApiController]
+ [Area("reports")]
+ [ApiVersion("1.0")]
+ [Route("v{version:apiVersion}/[area]/management-activities")]
+ [Route("[area]/management-activities")]
+ public class ManagementActivityController : ControllerBase
+ {
+ private readonly IManagementActivityService _managementActivityService;
+ private readonly IMapper _mapper;
+ private readonly ILogger _logger;
+
+ public ManagementActivityController(IManagementActivityService managementActivityService, IMapper mapper, ILogger logger)
+ {
+ _managementActivityService = managementActivityService;
+ _mapper = mapper;
+ _logger = logger;
+ }
+
+ ///
+ /// Exports Management Activities as CSV or Excel file.
+ /// Include 'Accept' header to request the appropriate export -
+ /// ["text/csv", "application/application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].
+ ///
+ ///
+ ///
+ [HttpGet]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces(ContentTypes.CONTENTTYPECSV, ContentTypes.CONTENTTYPEEXCELX)]
+ [ProducesResponseType(200)]
+ [SwaggerOperation(Tags = new[] { "management-activities", "report" })]
+ public IActionResult ExportManagementActivities(bool all = false)
+ {
+ var uri = new Uri(Request.GetDisplayUrl());
+ var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query);
+ return ExportManagementActivities(new ManagementActivityFilterModel(query), all);
+ }
+
+ ///
+ /// Exports Management Activities as CSV or Excel file.
+ /// Include 'Accept' header to request the appropriate export -
+ /// ["text/csv", "application/application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("filter")]
+ [HasPermission(Permissions.ManagementView)]
+ [Produces(ContentTypes.CONTENTTYPECSV, ContentTypes.CONTENTTYPEEXCELX)]
+ [ProducesResponseType(200)]
+ [SwaggerOperation(Tags = new[] { "management-activities", "report" })]
+ public IActionResult ExportManagementActivities([FromBody]ManagementActivityFilterModel filter, bool all = false)
+ {
+ _logger.LogInformation(
+ "Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
+ nameof(ActivitySearchController),
+ nameof(ExportManagementActivities),
+ User.GetUsername(),
+ DateTime.Now);
+
+ filter.ThrowBadRequestIfNull($"The request must include a filter.");
+ if (!filter.IsValid())
+ {
+ throw new BadRequestException("Lease filter must contain valid values.");
+ }
+
+ var acceptHeader = (string)Request.Headers["Accept"];
+ if (acceptHeader != ContentTypes.CONTENTTYPECSV && acceptHeader != ContentTypes.CONTENTTYPEEXCEL && acceptHeader != ContentTypes.CONTENTTYPEEXCELX)
+ {
+ throw new BadRequestException($"Invalid HTTP request header 'Accept:{acceptHeader}'.");
+ }
+
+ var allManagementActivities = _managementActivityService.GetPage((ManagementActivityFilter)filter, all);
+ var flatActivities = _mapper.Map>(allManagementActivities);
+
+ return acceptHeader.ToString() switch
+ {
+ ContentTypes.CONTENTTYPECSV => ReportHelper.GenerateCsv(flatActivities),
+ _ => ReportHelper.GenerateExcel(flatActivities, "ManagementActities")
+ };
+ }
+ }
+}
diff --git a/source/backend/api/Areas/Reports/Controllers/PropertyController.cs b/source/backend/api/Areas/Reports/Controllers/PropertyController.cs
index e36ac33e93..43c39f1174 100644
--- a/source/backend/api/Areas/Reports/Controllers/PropertyController.cs
+++ b/source/backend/api/Areas/Reports/Controllers/PropertyController.cs
@@ -4,16 +4,15 @@
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Helpers.Constants;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Helpers.Reporting;
using Pims.Api.Models.Base;
+using Pims.Core.Api.Exceptions;
using Pims.Core.Api.Policies;
+using Pims.Core.Security;
using Pims.Dal.Entities.Models;
using Pims.Dal.Repositories;
-using Pims.Core.Security;
using Swashbuckle.AspNetCore.Annotations;
-using Pims.Core.Api.Exceptions;
namespace Pims.Api.Areas.Reports.Controllers
{
diff --git a/source/backend/api/Areas/Reports/Controllers/UserController.cs b/source/backend/api/Areas/Reports/Controllers/UserController.cs
index 1fd1abd221..256be32f5f 100644
--- a/source/backend/api/Areas/Reports/Controllers/UserController.cs
+++ b/source/backend/api/Areas/Reports/Controllers/UserController.cs
@@ -4,13 +4,13 @@
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Helpers.Constants;
-using Pims.Core.Api.Exceptions;
using Pims.Api.Helpers.Extensions;
using Pims.Api.Helpers.Reporting;
using Pims.Api.Models.Base;
+using Pims.Core.Api.Exceptions;
using Pims.Core.Api.Policies;
-using Pims.Dal.Repositories;
using Pims.Core.Security;
+using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
using EModel = Pims.Dal.Entities.Models;
diff --git a/source/backend/api/Areas/Reports/Mapping/Management/ManagementActivityReportMap.cs b/source/backend/api/Areas/Reports/Mapping/Management/ManagementActivityReportMap.cs
new file mode 100644
index 0000000000..41e5caf425
--- /dev/null
+++ b/source/backend/api/Areas/Reports/Mapping/Management/ManagementActivityReportMap.cs
@@ -0,0 +1,23 @@
+using System.Linq;
+using Mapster;
+using Pims.Api.Areas.Reports.Models.Management;
+using Entity = Pims.Dal.Entities;
+
+namespace Pims.Api.Areas.Reports.Mapping.Management
+{
+ public class ManagementActivityReportMap : IRegister
+ {
+ public void Register(TypeAdapterConfig config)
+ {
+ config.NewConfig()
+ .Map(dest => dest.ManagementFileName, src => src.ManagementFile.FileName)
+ .Map(dest => dest.LegacyFileNum, src => src.ManagementFile.LegacyFileNum)
+ .Map(dest => dest.ActivityType, src => src.PropMgmtActivityTypeCodeNavigation.Description)
+ .Map(dest => dest.ActivitySubTypes, src => string.Join(",", src.PimsPropActivityMgmtActivities.Select(st => st.PropMgmtActivitySubtypeCodeNavigation.Description)))
+ .Map(dest => dest.ActivityStatusType, src => src.PropMgmtActivityStatusTypeCodeNavigation.Description)
+ .Map(dest => dest.RequestAddedDateOnly, src => src.RequestAddedDt)
+ .Map(dest => dest.CompletionDateOnly, src => src.CompletionDt)
+ .Map(dest => dest.Description, src => src.Description);
+ }
+ }
+}
diff --git a/source/backend/api/Areas/Reports/Models/Management/ManagementActivityReportModel.cs b/source/backend/api/Areas/Reports/Models/Management/ManagementActivityReportModel.cs
new file mode 100644
index 0000000000..0e3428bb6c
--- /dev/null
+++ b/source/backend/api/Areas/Reports/Models/Management/ManagementActivityReportModel.cs
@@ -0,0 +1,41 @@
+using System;
+using System.ComponentModel;
+
+namespace Pims.Api.Areas.Reports.Models.Management
+{
+ public class ManagementActivityReportModel
+ {
+
+ [DisplayName("Management File Name")]
+ [CsvHelper.Configuration.Attributes.Name("Management File Name")]
+ public string ManagementFileName { get; set; }
+
+ [DisplayName("Management File Number")]
+ [CsvHelper.Configuration.Attributes.Name("Management File Number")]
+ public string LegacyFileNum { get; set; }
+
+ [DisplayName("Type")]
+ [CsvHelper.Configuration.Attributes.Name("Type")]
+ public string ActivityType { get; set; }
+
+ [DisplayName("Sub-Types")]
+ [CsvHelper.Configuration.Attributes.Name("Sub-Types")]
+ public string ActivitySubTypes { get; set; }
+
+ [DisplayName("Status")]
+ [CsvHelper.Configuration.Attributes.Name("Status")]
+ public string ActivityStatusType { get; set; }
+
+ [DisplayName("Request Added Date")]
+ [CsvHelper.Configuration.Attributes.Name("Request Added Date")]
+ public DateOnly RequestAddedDateOnly { get; set; }
+
+ [DisplayName("Completion Date")]
+ [CsvHelper.Configuration.Attributes.Name("Completion Date")]
+ public DateOnly? CompletionDateOnly { get; set; }
+
+ [DisplayName("Description")]
+ [CsvHelper.Configuration.Attributes.Name("Description")]
+ public string Description { get; set; }
+ }
+}
diff --git a/source/backend/api/Areas/Research/Models/ResearchFilterModel.cs b/source/backend/api/Areas/Research/Models/ResearchFilterModel.cs
index 913b0caf43..08860f4651 100644
--- a/source/backend/api/Areas/Research/Models/ResearchFilterModel.cs
+++ b/source/backend/api/Areas/Research/Models/ResearchFilterModel.cs
@@ -101,7 +101,7 @@ public ResearchFilterModel(Dictionary(_lookupRepository.GetAllAcquisitionFileExpropiationRiskStatusTypes());
var llTeamProfileTypes = _mapper.Map(_lookupRepository.GetAllLlTeamProfileTypes());
var expropriationEventTypes = _mapper.Map(_lookupRepository.GetAllExpropriationEventTypes());
+ var managementFilePurposeTypes = _mapper.Map(_lookupRepository.GetAllManagementFilePurposeTypes());
+ var managementFileStatusTypes = _mapper.Map(_lookupRepository.GetAllManagementFileStatusTypes());
+ var managementFileProfileTypes = _mapper.Map(_lookupRepository.GetAllManagementFileProfileTypes());
var codes = new List
public class DocumentFileService : BaseService, IDocumentFileService
{
- private readonly IAcquisitionFileDocumentRepository _acquisitionFileDocumentRepository;
- private readonly IResearchFileDocumentRepository _researchFileDocumentRepository;
private readonly IDocumentService _documentService;
- private readonly IProjectRepository _projectRepository;
private readonly IDocumentRepository _documentRepository;
private readonly IDocumentQueueRepository _documentQueueRepository;
- private readonly ILeaseRepository _leaseRepository;
- private readonly IPropertyActivityDocumentRepository _propertyActivityDocumentRepository;
- private readonly IDispositionFileDocumentRepository _dispositionFileDocumentRepository;
+ private readonly IDocumentRelationshipRepository _acquisitionFileDocumentRepository;
+ private readonly IDocumentRelationshipRepository _researchFileDocumentRepository;
+ private readonly IDocumentRelationshipRepository _propertyActivityDocumentRepository;
+ private readonly IDocumentRelationshipRepository _leaseFileDocumentRepository;
+ private readonly IDocumentRelationshipRepository _projectDocumentRepository;
+ private readonly IDocumentRelationshipRepository _dispositionFileDocumentRepository;
+ private readonly IDocumentRelationshipRepository _managementFileDocumentRepository;
+ private readonly IDocumentRelationshipRepository _propertyDocumentRepository;
public DocumentFileService(
ClaimsPrincipal user,
ILogger logger,
- IAcquisitionFileDocumentRepository acquisitionFileDocumentRepository,
- IResearchFileDocumentRepository researchFileDocumentRepository,
- IDocumentService documentService,
- IProjectRepository projectRepository,
IDocumentRepository documentRepository,
- ILeaseRepository leaseRepository,
- IPropertyActivityDocumentRepository propertyActivityDocumentRepository,
- IDispositionFileDocumentRepository dispositionFileDocumentRepository,
+ IDocumentService documentService,
+ IDocumentRelationshipRepository acquisitionFileDocumentRepository,
+ IDocumentRelationshipRepository researchFileDocumentRepository,
+ IDocumentRelationshipRepository leaseFileDocumentRepository,
+ IDocumentRelationshipRepository projectDocumentRepository,
+ IDocumentRelationshipRepository propertyActivityDocumentRepository,
+ IDocumentRelationshipRepository dispositionFileDocumentRepository,
+ IDocumentRelationshipRepository managementFileDocumentRepository,
+ IDocumentRelationshipRepository propertyDocumentRepository,
IDocumentQueueRepository documentQueueRepository)
: base(user, logger)
{
- _acquisitionFileDocumentRepository = acquisitionFileDocumentRepository;
- _researchFileDocumentRepository = researchFileDocumentRepository;
_documentService = documentService;
- _projectRepository = projectRepository;
_documentRepository = documentRepository;
- _leaseRepository = leaseRepository;
+ _acquisitionFileDocumentRepository = acquisitionFileDocumentRepository;
+ _researchFileDocumentRepository = researchFileDocumentRepository;
+ _leaseFileDocumentRepository = leaseFileDocumentRepository;
+ _projectDocumentRepository = projectDocumentRepository;
_propertyActivityDocumentRepository = propertyActivityDocumentRepository;
_dispositionFileDocumentRepository = dispositionFileDocumentRepository;
+ _managementFileDocumentRepository = managementFileDocumentRepository;
+ _propertyDocumentRepository = propertyDocumentRepository;
_documentQueueRepository = documentQueueRepository;
}
public IList GetFileDocuments(FileType fileType, long fileId)
where T : PimsFileDocument
{
- Logger.LogInformation("Retrieving PIMS documents related to the file of type ${fileType}", fileType);
+ Logger.LogInformation("Retrieving PIMS documents related to the file of type {FileType}", fileType);
User.ThrowIfNotAuthorized(Permissions.DocumentView);
switch (fileType)
{
case FileType.Research:
User.ThrowIfNotAuthorized(Permissions.ResearchFileView);
- return _researchFileDocumentRepository.GetAllByResearchFile(fileId).Select(f => f as T).ToArray();
+ return _researchFileDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
case FileType.Acquisition:
User.ThrowIfNotAuthorized(Permissions.AcquisitionFileView);
- return _acquisitionFileDocumentRepository.GetAllByAcquisitionFile(fileId).Select(f => f as T).ToArray();
+ return _acquisitionFileDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
case FileType.Project:
User.ThrowIfNotAuthorized(Permissions.ProjectView);
- return _projectRepository.GetAllProjectDocuments(fileId).Select(f => f as T).ToArray();
+ return _projectDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
case FileType.Lease:
User.ThrowIfNotAuthorized(Permissions.LeaseView);
- return _leaseRepository.GetAllLeaseDocuments(fileId).Select(f => f as T).ToArray();
- case FileType.Management:
+ return _leaseFileDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
+ case FileType.ManagementActivity:
+ User.ThrowIfNotAuthorized(Permissions.ManagementView);
+ return _propertyActivityDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
+ case FileType.ManagementFile:
User.ThrowIfNotAuthorized(Permissions.ManagementView);
- return _propertyActivityDocumentRepository.GetAllByPropertyActivity(fileId).Select(f => f as T).ToArray();
+ return _managementFileDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
case FileType.Disposition:
User.ThrowIfNotAuthorized(Permissions.DispositionView);
- return _dispositionFileDocumentRepository.GetAllByDispositionFile(fileId).Select(f => f as T).ToArray();
+ return _dispositionFileDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
+ case FileType.Property:
+ User.ThrowIfNotAuthorized(Permissions.PropertyView);
+ return _propertyDocumentRepository.GetAllByParentId(fileId).Select(f => f as T).ToArray();
default:
- throw new BadRequestException("FileT type not valid to get documents.");
+ throw new BadRequestException("File type not valid to get documents.");
}
}
@@ -96,301 +108,112 @@ public async Task UploadAcquisitionDocument(long acquisitionFileId, DocumentUplo
{
Logger.LogInformation("Uploading document for single acquisition file");
User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.AcquisitionFileEdit);
- ValidateDocumentUpload(uploadRequest);
-
- PimsDocument pimsDocument = CreatePimsDocument(uploadRequest);
- _documentQueueRepository.SaveChanges();
-
- PimsAcquisitionFileDocument newAcquisitionDocument = new()
- {
- AcquisitionFileId = acquisitionFileId,
- DocumentId = pimsDocument.DocumentId,
- };
- _acquisitionFileDocumentRepository.AddAcquisition(newAcquisitionDocument);
-
- await GenerateQueuedDocumentItem(pimsDocument.DocumentId, uploadRequest);
- _acquisitionFileDocumentRepository.CommitTransaction();
-
- return;
+ await UploadDocument(acquisitionFileId, uploadRequest, _acquisitionFileDocumentRepository);
}
public async Task UploadResearchDocument(long researchFileId, DocumentUploadRequest uploadRequest)
{
Logger.LogInformation("Uploading document for single research file");
User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.ResearchFileEdit);
- ValidateDocumentUpload(uploadRequest);
-
- PimsDocument pimsDocument = CreatePimsDocument(uploadRequest);
- _documentQueueRepository.SaveChanges();
-
- PimsResearchFileDocument newFileDocument = new()
- {
- ResearchFileId = researchFileId,
- DocumentId = pimsDocument.DocumentId,
- };
- _researchFileDocumentRepository.AddResearch(newFileDocument);
-
- await GenerateQueuedDocumentItem(pimsDocument.DocumentId, uploadRequest);
- _documentQueueRepository.CommitTransaction();
-
- return;
+ await UploadDocument(researchFileId, uploadRequest, _researchFileDocumentRepository);
}
public async Task UploadProjectDocument(long projectId, DocumentUploadRequest uploadRequest)
{
Logger.LogInformation("Uploading document for single Project");
User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.ProjectEdit);
- ValidateDocumentUpload(uploadRequest);
-
- PimsDocument pimsDocument = CreatePimsDocument(uploadRequest);
- _documentQueueRepository.SaveChanges();
-
- PimsProjectDocument newFileDocument = new()
- {
- ProjectId = projectId,
- DocumentId = pimsDocument.DocumentId,
- };
- _projectRepository.AddProjectDocument(newFileDocument);
-
- await GenerateQueuedDocumentItem(pimsDocument.DocumentId, uploadRequest);
- _documentQueueRepository.CommitTransaction();
-
- return;
+ await UploadDocument(projectId, uploadRequest, _projectDocumentRepository);
}
public async Task UploadLeaseDocument(long leaseId, DocumentUploadRequest uploadRequest)
{
Logger.LogInformation("Uploading document for single Lease");
User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.LeaseEdit);
- ValidateDocumentUpload(uploadRequest);
-
- PimsDocument pimsDocument = CreatePimsDocument(uploadRequest);
- _documentQueueRepository.SaveChanges();
-
- PimsLeaseDocument newFileDocument = new()
- {
- LeaseId = leaseId,
- DocumentId = pimsDocument.DocumentId,
- };
- _leaseRepository.AddLeaseDocument(newFileDocument);
-
- await GenerateQueuedDocumentItem(pimsDocument.DocumentId, uploadRequest);
- _documentQueueRepository.CommitTransaction();
-
- return;
+ await UploadDocument(leaseId, uploadRequest, _leaseFileDocumentRepository);
}
public async Task UploadPropertyActivityDocument(long propertyActivityId, DocumentUploadRequest uploadRequest)
{
Logger.LogInformation("Uploading document for single Property Activity");
User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.ManagementEdit);
- ValidateDocumentUpload(uploadRequest);
-
- PimsDocument pimsDocument = CreatePimsDocument(uploadRequest);
- _documentQueueRepository.SaveChanges();
-
- PimsPropertyActivityDocument newFileDocument = new()
- {
- PimsPropertyActivityId = propertyActivityId,
- DocumentId = pimsDocument.DocumentId,
- };
- _propertyActivityDocumentRepository.AddPropertyActivityDocument(newFileDocument);
-
- await GenerateQueuedDocumentItem(pimsDocument.DocumentId, uploadRequest);
- _documentQueueRepository.CommitTransaction();
+ await UploadDocument(propertyActivityId, uploadRequest, _propertyActivityDocumentRepository);
+ }
- return;
+ public async Task UploadManagementFileDocument(long managementFileId, DocumentUploadRequest uploadRequest)
+ {
+ Logger.LogInformation("Uploading document for single management file");
+ User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.ManagementEdit);
+ await UploadDocument(managementFileId, uploadRequest, _managementFileDocumentRepository);
}
public async Task UploadDispositionDocument(long dispositionFileId, DocumentUploadRequest uploadRequest)
{
Logger.LogInformation("Uploading document for single disposition file");
User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.DispositionEdit);
- ValidateDocumentUpload(uploadRequest);
-
- PimsDocument pimsDocument = CreatePimsDocument(uploadRequest);
- _documentQueueRepository.SaveChanges();
-
- PimsDispositionFileDocument newFileDocument = new()
- {
- DispositionFileId = dispositionFileId,
- DocumentId = pimsDocument.DocumentId,
- };
- _dispositionFileDocumentRepository.AddDispositionDocument(newFileDocument);
-
- await GenerateQueuedDocumentItem(pimsDocument.DocumentId, uploadRequest);
- _documentQueueRepository.CommitTransaction();
+ await UploadDocument(dispositionFileId, uploadRequest, _dispositionFileDocumentRepository);
+ }
- return;
+ public async Task UploadPropertyDocument(long propertyId, DocumentUploadRequest uploadRequest)
+ {
+ Logger.LogInformation("Uploading document for single property file");
+ User.ThrowIfNotAllAuthorized(Permissions.DocumentAdd, Permissions.PropertyEdit);
+ await UploadDocument(propertyId, uploadRequest, _propertyDocumentRepository);
}
public async Task> DeleteResearchDocumentAsync(PimsResearchFileDocument researchFileDocument)
{
Logger.LogInformation("Deleting PIMS document for single research file");
User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.ResearchFileEdit);
-
- var result = new ExternalResponse() { Status = ExternalResponseStatus.NotExecuted };
- PimsDocument currentDocument = _documentRepository.Find(researchFileDocument.Document.DocumentId);
-
- if (currentDocument.MayanId.HasValue && currentDocument.MayanId.Value > 0)
- {
- result = await DeleteMayanDocument((long)currentDocument.MayanId);
- currentDocument = RemoveDocumentMayanID(currentDocument);
- _documentRepository.CommitTransaction();
- }
-
- using var transaction = _documentRepository.BeginTransaction();
-
- DeleteQueuedDocumentItem(currentDocument.DocumentId);
- _researchFileDocumentRepository.DeleteResearch(researchFileDocument);
- DeleteDocument(currentDocument);
-
- _documentRepository.SaveChanges();
- transaction.Commit();
-
- return result;
+ return await DeletePropertyDocumentAsync(researchFileDocument, _researchFileDocumentRepository);
}
public async Task> DeleteProjectDocumentAsync(PimsProjectDocument projectDocument)
{
Logger.LogInformation("Deleting PIMS document for single Project");
User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.ProjectEdit);
-
- var result = new ExternalResponse() { Status = ExternalResponseStatus.NotExecuted };
- PimsDocument currentDocument = _documentRepository.Find(projectDocument.Document.DocumentId);
-
- if (currentDocument.MayanId.HasValue && currentDocument.MayanId.Value > 0)
- {
- result = await DeleteMayanDocument((long)currentDocument.MayanId);
- currentDocument = RemoveDocumentMayanID(currentDocument);
- _documentRepository.CommitTransaction();
- }
-
- using var transaction = _documentRepository.BeginTransaction();
-
- DeleteQueuedDocumentItem(currentDocument.DocumentId);
- _projectRepository.DeleteProjectDocument(projectDocument.ProjectDocumentId);
- DeleteDocument(currentDocument);
-
- _documentRepository.SaveChanges();
- transaction.Commit();
-
- return result;
+ return await DeletePropertyDocumentAsync(projectDocument, _projectDocumentRepository);
}
public async Task> DeleteAcquisitionDocumentAsync(PimsAcquisitionFileDocument acquisitionFileDocument)
{
Logger.LogInformation("Deleting PIMS document for single acquisition file");
User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.AcquisitionFileEdit);
-
- var result = new ExternalResponse() { Status = ExternalResponseStatus.NotExecuted };
- PimsDocument currentDocument = _documentRepository.Find(acquisitionFileDocument.Document.DocumentId);
-
- if (currentDocument.MayanId.HasValue && currentDocument.MayanId.Value > 0)
- {
- result = await DeleteMayanDocument((long)acquisitionFileDocument.Document.MayanId);
- currentDocument = RemoveDocumentMayanID(currentDocument);
- _documentRepository.CommitTransaction();
- }
-
- using var transaction = _documentRepository.BeginTransaction();
-
- DeleteQueuedDocumentItem(acquisitionFileDocument.DocumentId);
-
- _acquisitionFileDocumentRepository.DeleteAcquisition(acquisitionFileDocument);
-
- DeleteDocument(currentDocument);
-
- _documentRepository.SaveChanges();
- transaction.Commit();
-
- return result;
+ return await DeletePropertyDocumentAsync(acquisitionFileDocument, _acquisitionFileDocumentRepository);
}
public async Task> DeleteLeaseDocumentAsync(PimsLeaseDocument leaseDocument)
{
Logger.LogInformation("Deleting PIMS document for single lease");
User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.LeaseEdit);
-
- var result = new ExternalResponse() { Status = ExternalResponseStatus.NotExecuted };
- PimsDocument currentDocument = _documentRepository.Find(leaseDocument.Document.DocumentId);
-
- // 1 - Delete Mayan first.
- if (currentDocument.MayanId.HasValue && currentDocument.MayanId.Value > 0)
- {
- result = await DeleteMayanDocument((long)currentDocument.MayanId);
- currentDocument = RemoveDocumentMayanID(currentDocument);
- _documentRepository.CommitTransaction();
- }
-
- using var transaction = _documentRepository.BeginTransaction();
-
- DeleteQueuedDocumentItem(currentDocument.DocumentId);
- _leaseRepository.DeleteLeaseDocument(leaseDocument.LeaseDocumentId);
-
- DeleteDocument(currentDocument);
-
- _documentRepository.SaveChanges();
- transaction.Commit();
-
- return result;
+ return await DeletePropertyDocumentAsync(leaseDocument, _leaseFileDocumentRepository);
}
public async Task> DeletePropertyActivityDocumentAsync(PimsPropertyActivityDocument propertyActivityDocument)
{
Logger.LogInformation("Deleting PIMS document for single Property Activity");
User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.ManagementEdit);
+ return await DeletePropertyDocumentAsync(propertyActivityDocument, _propertyActivityDocumentRepository);
+ }
- var result = new ExternalResponse() { Status = ExternalResponseStatus.NotExecuted };
- PimsDocument currentDocument = _documentRepository.Find(propertyActivityDocument.Document.DocumentId);
-
- if (currentDocument.MayanId.HasValue && currentDocument.MayanId.Value > 0)
- {
- result = await DeleteMayanDocument((long)currentDocument.MayanId);
- currentDocument = RemoveDocumentMayanID(currentDocument);
- _documentRepository.CommitTransaction();
- }
-
- using var transaction = _documentRepository.BeginTransaction();
-
- DeleteQueuedDocumentItem(currentDocument.DocumentId);
-
- _propertyActivityDocumentRepository.DeletePropertyActivityDocument(propertyActivityDocument);
- DeleteDocument(currentDocument);
-
- _documentRepository.SaveChanges();
- transaction.Commit();
-
- return result;
+ public async Task> DeleteManagementFileDocumentAsync(PimsManagementFileDocument managementFileDocument)
+ {
+ Logger.LogInformation("Deleting PIMS document for single management file");
+ User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.ManagementEdit);
+ return await DeletePropertyDocumentAsync(managementFileDocument, _managementFileDocumentRepository);
}
public async Task> DeleteDispositionDocumentAsync(PimsDispositionFileDocument dispositionFileDocument)
{
Logger.LogInformation("Deleting PIMS document for single disposition file");
User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.DispositionEdit);
+ return await DeletePropertyDocumentAsync(dispositionFileDocument, _dispositionFileDocumentRepository);
+ }
- var result = new ExternalResponse() { Status = ExternalResponseStatus.NotExecuted };
- PimsDocument currentDocument = _documentRepository.Find(dispositionFileDocument.DocumentId);
-
- if (currentDocument.MayanId.HasValue && currentDocument.MayanId.Value > 0)
- {
- result = await DeleteMayanDocument((long)currentDocument.MayanId);
- currentDocument = RemoveDocumentMayanID(currentDocument);
- _documentRepository.CommitTransaction(); // leave trace when mayan document deleted.
- }
-
- using var transaction = _documentRepository.BeginTransaction();
-
- DeleteQueuedDocumentItem(currentDocument.DocumentId);
-
- _dispositionFileDocumentRepository.DeleteDispositionDocument(dispositionFileDocument);
-
- DeleteDocument(currentDocument);
-
- _documentRepository.SaveChanges();
- transaction.Commit();
-
- return result;
+ public async Task> DeletePropertyDocumentAsync(PimsPropertyDocument propertyDocument)
+ {
+ Logger.LogInformation("Deleting PIMS document for single property file");
+ User.ThrowIfNotAllAuthorized(Permissions.DocumentDelete, Permissions.PropertyEdit);
+ return await DeletePropertyDocumentAsync(propertyDocument, _propertyDocumentRepository);
}
private static void ValidateDocumentUpload(DocumentUploadRequest uploadRequest)
@@ -399,10 +222,31 @@ private static void ValidateDocumentUpload(DocumentUploadRequest uploadRequest)
if (!DocumentService.IsValidDocumentExtension(uploadRequest.File.FileName))
{
- throw new BusinessRuleViolationException($"This file has an invalid file extension.");
+ throw new BusinessRuleViolationException("This file has an invalid file extension.");
}
}
+ private async Task UploadDocument(long parentId, DocumentUploadRequest uploadRequest, IDocumentRelationshipRepository documentRelationshipRepository)
+ where T : PimsFileDocument, new()
+ {
+ ValidateDocumentUpload(uploadRequest);
+
+ PimsDocument pimsDocument = CreatePimsDocument(uploadRequest);
+ _documentQueueRepository.SaveChanges();
+
+ T newFileDocument = new()
+ {
+ FileId = parentId,
+ InternalDocumentId = pimsDocument.DocumentId,
+ };
+ documentRelationshipRepository.AddDocument(newFileDocument);
+
+ await GenerateQueuedDocumentItem(pimsDocument.DocumentId, uploadRequest);
+ _documentQueueRepository.CommitTransaction();
+
+ return;
+ }
+
private PimsDocument CreatePimsDocument(DocumentUploadRequest uploadRequest, string documentExternalId = null)
{
// Create the pims document
@@ -431,6 +275,32 @@ private async Task GenerateQueuedDocumentItem(long documentId, DocumentUploadReq
_documentQueueRepository.Add(queueDocument);
}
+ private async Task> DeletePropertyDocumentAsync(T propertyDocument, IDocumentRelationshipRepository documentRelationshipRepository)
+ where T : PimsFileDocument
+ {
+ var result = new ExternalResponse() { Status = ExternalResponseStatus.NotExecuted };
+ PimsDocument currentDocument = _documentRepository.Find(propertyDocument.InternalDocumentId);
+
+ if (currentDocument.MayanId.HasValue && currentDocument.MayanId.Value > 0)
+ {
+ result = await DeleteMayanDocument((long)currentDocument.MayanId);
+ currentDocument = RemoveDocumentMayanID(currentDocument);
+ _documentRepository.CommitTransaction(); // leave trace when mayan document deleted.
+ }
+
+ using var transaction = _documentRepository.BeginTransaction();
+
+ DeleteQueuedDocumentItem(currentDocument.DocumentId);
+
+ documentRelationshipRepository.DeleteDocument(propertyDocument);
+ _documentRepository.SaveChanges();
+
+ DeletePimsDocument(currentDocument);
+ await transaction.CommitAsync();
+
+ return result;
+ }
+
private async Task> DeleteMayanDocument(long mayanDocumentId)
{
var result = await _documentService.DeleteMayanStorageDocumentAsync(mayanDocumentId);
@@ -453,7 +323,7 @@ private void DeleteQueuedDocumentItem(long documentId)
var documentQueuedItem = _documentQueueRepository.GetByDocumentId(documentId);
if (documentQueuedItem == null)
{
- Logger.LogWarning("Document Queue item not found for document {documentId}", documentId);
+ Logger.LogWarning("Document Queue item not found for document {DocumentId}", documentId);
return;
}
if (documentQueuedItem.DocumentQueueStatusTypeCode == DocumentQueueStatusTypes.PENDING.ToString()
@@ -463,19 +333,19 @@ private void DeleteQueuedDocumentItem(long documentId)
}
bool deleted = _documentQueueRepository.Delete(documentQueuedItem);
- if(!deleted)
+ if (!deleted)
{
- Logger.LogWarning("Failed to delete Queued Document {documentId}", documentId);
+ Logger.LogWarning("Failed to delete Queued Document {DocumentId}", documentId);
throw new InvalidOperationException("Could not delete document queue item");
}
}
- private void DeleteDocument(PimsDocument document)
+ private void DeletePimsDocument(PimsDocument document)
{
bool deleted = _documentRepository.DeleteDocument(document);
if (!deleted)
{
- Logger.LogWarning("Failed to delete Document {documentId}", document.DocumentId);
+ Logger.LogWarning("Failed to delete Document {DocumentId}", document.DocumentId);
throw new InvalidOperationException("Could not delete document");
}
}
diff --git a/source/backend/api/Services/DocumentQueueService.cs b/source/backend/api/Services/DocumentQueueService.cs
index b000931231..9c6c744bb1 100644
--- a/source/backend/api/Services/DocumentQueueService.cs
+++ b/source/backend/api/Services/DocumentQueueService.cs
@@ -98,7 +98,7 @@ public IEnumerable SearchDocumentQueue(DocumentQueueFilter fi
documentsBelowMaxFileSize.Add(currentDocument);
}
});
- if(documentsBelowMaxFileSize.Count == 0 && queuedDocuments.Any())
+ if (documentsBelowMaxFileSize.Count == 0 && queuedDocuments.Any())
{
documentsBelowMaxFileSize.Add(queuedDocuments.FirstOrDefault());
}
diff --git a/source/backend/api/Services/DocumentService.cs b/source/backend/api/Services/DocumentService.cs
index e458d594ff..cb45fd0fbb 100644
--- a/source/backend/api/Services/DocumentService.cs
+++ b/source/backend/api/Services/DocumentService.cs
@@ -97,6 +97,12 @@ public DocumentService(
configuration.Bind(MayanConfigSectionKey, _config);
}
+ public static bool IsValidDocumentExtension(string fileName)
+ {
+ var fileNameExtension = Path.GetExtension(fileName).Replace(".", string.Empty).ToLower();
+ return ValidExtensions.Contains(fileNameExtension);
+ }
+
public IList GetPimsDocumentTypes()
{
this.Logger.LogInformation("Retrieving PIMS document types");
@@ -107,8 +113,8 @@ public IList GetPimsDocumentTypes()
public IList GetPimsDocumentTypes(DocumentRelationType relationshipType)
{
- this.Logger.LogInformation("Retrieving PIMS document types for relationship type {relationshipType}", relationshipType);
- this.User.ThrowIfNotAuthorized(Permissions.DocumentView);
+ Logger.LogInformation("Retrieving PIMS document types for relationship type {RelationshipType}", relationshipType);
+ User.ThrowIfNotAuthorized(Permissions.DocumentView);
string categoryType;
switch (relationshipType)
@@ -125,7 +131,9 @@ public IList GetPimsDocumentTypes(DocumentRelationType relation
case DocumentRelationType.Projects:
categoryType = "PROJECT";
break;
+ case DocumentRelationType.ManagementActivities:
case DocumentRelationType.ManagementFiles:
+ case DocumentRelationType.Properties:
categoryType = "MANAGEMENT";
break;
case DocumentRelationType.DispositionFiles:
@@ -406,7 +414,7 @@ public async Task> DeleteMayanStorageDocumentAsync(long
User.ThrowIfNotAuthorized(Permissions.DocumentDelete);
ExternalResponse result = await documentStorageRepository.TryDeleteDocument(mayanDocumentId);
- if(result.Status == ExternalResponseStatus.Error && result.HttpStatusCode == HttpStatusCode.NotFound)
+ if (result.Status == ExternalResponseStatus.Error && result.HttpStatusCode == HttpStatusCode.NotFound)
{
return result;
}
@@ -610,12 +618,6 @@ public async Task DownloadFilePageImageAsync(long mayanDocu
return result;
}
- public static bool IsValidDocumentExtension(string fileName)
- {
- var fileNameExtension = Path.GetExtension(fileName).Replace(".", string.Empty).ToLower();
- return ValidExtensions.Contains(fileNameExtension);
- }
-
private async Task PrecacheDocumentPreviews(long documentId, long documentFileId)
{
this.Logger.LogInformation("Precaching the first {_config.PreviewPages} pages in document {documentId}, file {documentFileId}", _config.PreviewPages, documentId, documentFileId);
diff --git a/source/backend/api/Services/DocumentSyncService.cs b/source/backend/api/Services/DocumentSyncService.cs
index fca48277a9..be57b73a22 100644
--- a/source/backend/api/Services/DocumentSyncService.cs
+++ b/source/backend/api/Services/DocumentSyncService.cs
@@ -184,7 +184,7 @@ public DocumentSyncResponse SyncPimsDocumentTypes(SyncModel model)
var needsCategoryUpdate = !(subtypeCodes.All(documentTypeModel.Categories.Contains) && subtypeCodes.Count == documentTypeModel.Categories.Count);
var needsOrderUpdate = matchingDocumentType.DisplayOrder != documentTypeModel.DisplayOrder;
var needsToBeEnabled = matchingDocumentType.IsDisabled == true;
- if (needsLabelUpdate || needsPurposeUpdate|| needsCategoryUpdate || needsOrderUpdate || needsToBeEnabled)
+ if (needsLabelUpdate || needsPurposeUpdate || needsCategoryUpdate || needsOrderUpdate || needsToBeEnabled)
{
matchingDocumentType.DocumentTypeDescription = documentTypeModel.Label;
matchingDocumentType.DocumentTypeDefinition = documentTypeModel.Purpose;
diff --git a/source/backend/api/Services/ICompensationRequisitionService.cs b/source/backend/api/Services/ICompensationRequisitionService.cs
index a1f1fff32f..7546a2f464 100644
--- a/source/backend/api/Services/ICompensationRequisitionService.cs
+++ b/source/backend/api/Services/ICompensationRequisitionService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using Pims.Api.Models.CodeTypes;
using Pims.Dal.Entities;
@@ -25,5 +26,15 @@ public interface ICompensationRequisitionService
IEnumerable GetCompensationRequisitionAcquisitionPayees(long compReqId);
IEnumerable GetCompensationRequisitionLeasePayees(long compReqId);
+
+ PimsCompensationRequisition GetCompensationRequisitionAtTime(long compReqId, DateTime time);
+
+ IEnumerable GetCompensationRequisitionAcqPropertiesAtTime(long compReqId, DateTime time);
+
+ IEnumerable GetCompensationRequisitionLeasePropertiesAtTime(long compReqId, DateTime time);
+
+ IEnumerable GetCompensationRequisitionAcquisitionPayeesAtTime(long compReqId, DateTime time);
+
+ IEnumerable GetCompensationRequisitionLeasePayeesAtTime(long compReqId, DateTime time);
}
}
diff --git a/source/backend/api/Services/IDocumentFileService.cs b/source/backend/api/Services/IDocumentFileService.cs
index aa56e119fb..24b98372db 100644
--- a/source/backend/api/Services/IDocumentFileService.cs
+++ b/source/backend/api/Services/IDocumentFileService.cs
@@ -25,8 +25,12 @@ public IList GetFileDocuments(FileType fileType, long fileId)
Task UploadPropertyActivityDocument(long propertyActivityId, DocumentUploadRequest uploadRequest);
+ Task UploadManagementFileDocument(long managementFileId, DocumentUploadRequest uploadRequest);
+
Task UploadDispositionDocument(long dispositionFileId, DocumentUploadRequest uploadRequest);
+ Task UploadPropertyDocument(long propertyId, DocumentUploadRequest uploadRequest);
+
Task> DeleteResearchDocumentAsync(PimsResearchFileDocument researchFileDocument);
Task> DeleteAcquisitionDocumentAsync(PimsAcquisitionFileDocument acquisitionFileDocument);
@@ -37,7 +41,10 @@ public IList GetFileDocuments(FileType fileType, long fileId)
Task> DeletePropertyActivityDocumentAsync(PimsPropertyActivityDocument propertyActivityDocument);
+ Task> DeleteManagementFileDocumentAsync(PimsManagementFileDocument managementFileDocument);
+
Task> DeleteDispositionDocumentAsync(PimsDispositionFileDocument dispositionFileDocument);
+ Task> DeletePropertyDocumentAsync(PimsPropertyDocument propertyDocument);
}
}
diff --git a/source/backend/api/Services/IManagementActivityService.cs b/source/backend/api/Services/IManagementActivityService.cs
new file mode 100644
index 0000000000..0f74d8e863
--- /dev/null
+++ b/source/backend/api/Services/IManagementActivityService.cs
@@ -0,0 +1,10 @@
+using Pims.Dal.Entities;
+using Pims.Dal.Entities.Models;
+
+namespace Pims.Api.Services
+{
+ public interface IManagementActivityService
+ {
+ Paged GetPage(ManagementActivityFilter filter, bool? all = false);
+ }
+}
diff --git a/source/backend/api/Services/IManagementFileService.cs b/source/backend/api/Services/IManagementFileService.cs
new file mode 100644
index 0000000000..a49d6f9252
--- /dev/null
+++ b/source/backend/api/Services/IManagementFileService.cs
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+using Pims.Dal.Entities;
+using Pims.Dal.Entities.Models;
+using Pims.Dal.Exceptions;
+
+namespace Pims.Api.Services
+{
+ public interface IManagementFileService
+ {
+ PimsManagementFile GetById(long id);
+
+ PimsManagementFile Add(PimsManagementFile managementFile, IEnumerable userOverrides);
+
+ PimsManagementFile Update(long id, PimsManagementFile managementFile, IEnumerable userOverrides);
+
+ LastUpdatedByModel GetLastUpdateInformation(long managementFileId);
+
+ IEnumerable GetProperties(long id);
+
+ IEnumerable GetTeamMembers();
+
+ PimsManagementFile UpdateProperties(PimsManagementFile managementFile, IEnumerable userOverrides);
+
+ Paged GetPage(ManagementFilter filter);
+ }
+}
diff --git a/source/backend/api/Services/INoteService.cs b/source/backend/api/Services/INoteService.cs
index 2a78fb523a..f816b6b43a 100644
--- a/source/backend/api/Services/INoteService.cs
+++ b/source/backend/api/Services/INoteService.cs
@@ -1,20 +1,31 @@
using System.Collections.Generic;
using Pims.Api.Constants;
-using Pims.Api.Models.Concepts.Note;
using Pims.Dal.Entities;
namespace Pims.Api.Services
{
public interface INoteService
{
- NoteModel GetById(long id);
+ PimsNote GetById(long id);
- EntityNoteModel Add(NoteType type, EntityNoteModel model);
+ PimsAcquisitionFileNote AddAcquisitionFileNote(PimsAcquisitionFileNote acquisitionFileNote);
- NoteModel Update(NoteModel model);
+ PimsDispositionFileNote AddDispositionFileNote(PimsDispositionFileNote dispositionFileNote);
+
+ PimsLeaseNote AddLeaseNote(PimsLeaseNote leaseNote);
+
+ PimsManagementFileNote AddManagementFileNote(PimsManagementFileNote managementFileNote);
+
+ PimsProjectNote AddProjectNote(PimsProjectNote projectNote);
+
+ PimsPropertyNote AddPropertyNote(PimsPropertyNote propertyNote);
+
+ PimsResearchFileNote AddResearchFileNote(PimsResearchFileNote researchFileNote);
+
+ PimsNote Update(PimsNote note);
bool DeleteNote(NoteType type, long noteId, bool commitTransaction = true);
- IEnumerable GetNotes(NoteType type, long entityId);
+ IEnumerable GetNotes(NoteType type, long parentId);
}
}
diff --git a/source/backend/api/Services/IPropertyService.cs b/source/backend/api/Services/IPropertyService.cs
index cd7c81ab22..4ef106edef 100644
--- a/source/backend/api/Services/IPropertyService.cs
+++ b/source/backend/api/Services/IPropertyService.cs
@@ -35,14 +35,20 @@ public interface IPropertyService
IList GetActivities(long propertyId);
- PimsPropertyActivity GetActivity(long propertyId, long activityId);
+ IList GetFileActivities(long managementFileId);
+
+ PimsPropertyActivity GetActivity(long activityId);
+
+ IEnumerable GetActivitiesByPropertyIds(IEnumerable propertyIds);
PimsPropertyActivity CreateActivity(PimsPropertyActivity propertyActivity);
- PimsPropertyActivity UpdateActivity(long propertyId, long activityId, PimsPropertyActivity propertyActivity);
+ PimsPropertyActivity UpdateActivity(PimsPropertyActivity propertyActivity);
bool DeleteActivity(long activityId);
+ bool DeleteFileActivity(long managementFileId, long activityId);
+
PimsProperty PopulateNewProperty(PimsProperty property, bool isOwned = false, bool isPropertyOfInterest = true);
void UpdateLocation(PimsProperty incomingProperty, ref PimsProperty propertyToUpdate, IEnumerable overrideCodes, bool allowRetired = false);
diff --git a/source/backend/api/Services/LeasePaymentService.cs b/source/backend/api/Services/LeasePaymentService.cs
index 8d881e84ac..a403db3aa0 100644
--- a/source/backend/api/Services/LeasePaymentService.cs
+++ b/source/backend/api/Services/LeasePaymentService.cs
@@ -26,6 +26,49 @@ public LeasePaymentService(ILeasePeriodRepository leasePeriodRepository, ILeaseP
_logger = logger;
}
+ public static string GetPaymentStatus(PimsLeasePayment payment, PimsLeasePeriod parent)
+ {
+ if (!Enum.TryParse(payment.LeasePaymentCategoryTypeCode, out LeasePaymentCategoryTypes leasePaymentCategoryType))
+ {
+ payment.LeasePaymentCategoryTypeCode = LeasePaymentCategoryTypes.BASE.ToString();
+ }
+ decimal? expectedTotal;
+ switch (leasePaymentCategoryType)
+ {
+ case LeasePaymentCategoryTypes.VBL:
+ expectedTotal = (parent?.VblRentAgreedPmt ?? 0) + (parent?.VblRentGstAmount ?? 0);
+ break;
+ case LeasePaymentCategoryTypes.ADDL:
+ expectedTotal = (parent?.AddlRentAgreedPmt ?? 0) + (parent?.AddlRentGstAmount ?? 0);
+ break;
+ case LeasePaymentCategoryTypes.BASE:
+ expectedTotal = (parent?.PaymentAmount ?? 0) + (parent?.GstAmount ?? 0);
+ break;
+ default:
+ throw new InvalidOperationException();
+ }
+ if (payment?.PaymentAmountTotal == 0)
+ {
+ return PimsLeasePaymentStatusTypes.UNPAID;
+ }
+ else if (payment?.PaymentAmountTotal < expectedTotal)
+ {
+ return PimsLeasePaymentStatusTypes.PARTIAL;
+ }
+ else if (payment?.PaymentAmountTotal == expectedTotal)
+ {
+ return PimsLeasePaymentStatusTypes.PAID;
+ }
+ else if (payment?.PaymentAmountTotal > expectedTotal)
+ {
+ return PimsLeasePaymentStatusTypes.OVERPAID;
+ }
+ else
+ {
+ throw new InvalidOperationException("Invalid payment value provided");
+ }
+ }
+
public IEnumerable GetAllByDateRange(DateTime startDate, DateTime endDate)
{
return _leasePaymentRepository.GetAllTracking(startDate, endDate);
@@ -85,49 +128,6 @@ public PimsLeasePayment AddPayment(long leaseId, PimsLeasePayment payment)
return updatedPayment;
}
- public static string GetPaymentStatus(PimsLeasePayment payment, PimsLeasePeriod parent)
- {
- if (!Enum.TryParse(payment.LeasePaymentCategoryTypeCode, out LeasePaymentCategoryTypes leasePaymentCategoryType))
- {
- payment.LeasePaymentCategoryTypeCode = LeasePaymentCategoryTypes.BASE.ToString();
- }
- decimal? expectedTotal;
- switch (leasePaymentCategoryType)
- {
- case LeasePaymentCategoryTypes.VBL:
- expectedTotal = (parent?.VblRentAgreedPmt ?? 0) + (parent?.VblRentGstAmount ?? 0);
- break;
- case LeasePaymentCategoryTypes.ADDL:
- expectedTotal = (parent?.AddlRentAgreedPmt ?? 0) + (parent?.AddlRentGstAmount ?? 0);
- break;
- case LeasePaymentCategoryTypes.BASE:
- expectedTotal = (parent?.PaymentAmount ?? 0) + (parent?.GstAmount ?? 0);
- break;
- default:
- throw new InvalidOperationException();
- }
- if (payment?.PaymentAmountTotal == 0)
- {
- return PimsLeasePaymentStatusTypes.UNPAID;
- }
- else if (payment?.PaymentAmountTotal < expectedTotal)
- {
- return PimsLeasePaymentStatusTypes.PARTIAL;
- }
- else if (payment?.PaymentAmountTotal == expectedTotal)
- {
- return PimsLeasePaymentStatusTypes.PAID;
- }
- else if (payment?.PaymentAmountTotal > expectedTotal)
- {
- return PimsLeasePaymentStatusTypes.OVERPAID;
- }
- else
- {
- throw new InvalidOperationException("Invalid payment value provided");
- }
- }
-
///
/// Validate that the payment received date is part of the parent period.
///
diff --git a/source/backend/api/Services/LeasePeriodService.cs b/source/backend/api/Services/LeasePeriodService.cs
index f179371f03..ee92c0d1af 100644
--- a/source/backend/api/Services/LeasePeriodService.cs
+++ b/source/backend/api/Services/LeasePeriodService.cs
@@ -122,7 +122,7 @@ private void ValidateUpdateRules(PimsLeasePeriod period, long periodId)
{
throw new InvalidOperationException("Period must be 'exercised' if payments have been made.");
}
- if(leasePeriodToUpdate.IsVariablePayment != period.IsVariablePayment)
+ if (leasePeriodToUpdate.IsVariablePayment != period.IsVariablePayment)
{
throw new InvalidOperationException("Period payment variability may not be changed after period creation.");
}
diff --git a/source/backend/api/Services/LeaseReportsService.cs b/source/backend/api/Services/LeaseReportsService.cs
index 7ad2865c9e..8cab959dc1 100644
--- a/source/backend/api/Services/LeaseReportsService.cs
+++ b/source/backend/api/Services/LeaseReportsService.cs
@@ -3,10 +3,9 @@
using System.Linq;
using System.Security.Claims;
using Pims.Core.Extensions;
+using Pims.Core.Security;
using Pims.Dal.Entities;
-using Pims.Dal.Helpers.Extensions;
using Pims.Dal.Repositories;
-using Pims.Core.Security;
using static Pims.Dal.Entities.PimsLeaseStatusType;
namespace Pims.Api.Services
diff --git a/source/backend/api/Services/LeaseService.cs b/source/backend/api/Services/LeaseService.cs
index fb64a3933d..31e44f335f 100644
--- a/source/backend/api/Services/LeaseService.cs
+++ b/source/backend/api/Services/LeaseService.cs
@@ -30,7 +30,7 @@ public class LeaseService : BaseService, ILeaseService
private readonly IPropertyImprovementRepository _propertyImprovementRepository;
private readonly IPropertyRepository _propertyRepository;
private readonly IPropertyLeaseRepository _propertyLeaseRepository;
- private readonly IEntityNoteRepository _entityNoteRepository;
+ private readonly INoteRelationshipRepository _entityNoteRepository;
private readonly IInsuranceRepository _insuranceRepository;
private readonly ILeaseStakeholderRepository _stakeholderRepository;
private readonly ICompensationRequisitionRepository _compensationRequisitionRepository;
@@ -50,7 +50,7 @@ public LeaseService(
IPropertyRepository propertyRepository,
IPropertyLeaseRepository propertyLeaseRepository,
IPropertyImprovementRepository propertyImprovementRepository,
- IEntityNoteRepository entityNoteRepository,
+ INoteRelationshipRepository entityNoteRepository,
IInsuranceRepository insuranceRepository,
ILeaseStakeholderRepository stakeholderRepository,
ICompensationRequisitionRepository compensationRequisitionRepository,
@@ -275,7 +275,7 @@ public PimsLease Update(PimsLease lease, IEnumerable userOverr
{
PimsLeaseNote newLeaseNote = GeneratePimsLeaseNote(currentLease, lease);
- _entityNoteRepository.Add(newLeaseNote);
+ _entityNoteRepository.AddNoteRelationship(newLeaseNote);
}
ValidateRenewalDates(lease, currentLease, userOverrides);
@@ -511,6 +511,27 @@ public bool DeleteConsultation(long consultationId)
return deleteResult;
}
+ public IEnumerable GetTeamMembers()
+ {
+ _logger.LogInformation("Getting lease team members");
+ _user.ThrowIfNotAuthorized(Permissions.LeaseView);
+
+ var pimsUser = _userRepository.GetUserInfoByKeycloakUserId(_user.GetUserKey());
+ var userRegions = pimsUser.PimsRegionUsers.Select(r => r.RegionCode).ToHashSet();
+ long? contractorPersonId = pimsUser.IsContractor ? pimsUser.PersonId : null;
+
+ var teamMembers = _leaseRepository.GetTeamMembers(userRegions, contractorPersonId);
+
+ var persons = teamMembers.Where(x => x.Person != null).GroupBy(x => x.PersonId).Select(x => x.First()).ToList();
+ var organizations = teamMembers.Where(x => x.Organization != null).GroupBy(x => x.OrganizationId).Select(x => x.First()).ToList();
+
+ List teamFilterOptions = new();
+ teamFilterOptions.AddRange(persons);
+ teamFilterOptions.AddRange(organizations);
+
+ return teamFilterOptions;
+ }
+
private static void ValidateRenewalDates(PimsLease lease, PimsLease currentLease, IEnumerable userOverrides)
{
if (lease.LeaseStatusTypeCode != PimsLeaseStatusTypes.ACTIVE)
@@ -811,26 +832,5 @@ private void ValidateStakeholdersDependency(long leaseId, IEnumerable GetTeamMembers()
- {
- _logger.LogInformation("Getting lease team members");
- _user.ThrowIfNotAuthorized(Permissions.LeaseView);
-
- var pimsUser = _userRepository.GetUserInfoByKeycloakUserId(_user.GetUserKey());
- var userRegions = pimsUser.PimsRegionUsers.Select(r => r.RegionCode).ToHashSet();
- long? contractorPersonId = pimsUser.IsContractor ? pimsUser.PersonId : null;
-
- var teamMembers = _leaseRepository.GetTeamMembers(userRegions, contractorPersonId);
-
- var persons = teamMembers.Where(x => x.Person != null).GroupBy(x => x.PersonId).Select(x => x.First()).ToList();
- var organizations = teamMembers.Where(x => x.Organization != null).GroupBy(x => x.OrganizationId).Select(x => x.First()).ToList();
-
- List teamFilterOptions = new();
- teamFilterOptions.AddRange(persons);
- teamFilterOptions.AddRange(organizations);
-
- return teamFilterOptions;
- }
}
}
diff --git a/source/backend/api/Services/ManagementActivityService.cs b/source/backend/api/Services/ManagementActivityService.cs
new file mode 100644
index 0000000000..331d99b0e9
--- /dev/null
+++ b/source/backend/api/Services/ManagementActivityService.cs
@@ -0,0 +1,36 @@
+using System.Security.Claims;
+using Microsoft.Extensions.Logging;
+using Pims.Core.Extensions;
+using Pims.Core.Security;
+using Pims.Dal.Entities;
+using Pims.Dal.Entities.Models;
+using Pims.Dal.Repositories;
+
+namespace Pims.Api.Services
+{
+ public class ManagementActivityService : IManagementActivityService
+ {
+ private readonly ClaimsPrincipal _user;
+ private readonly ILogger _logger;
+ private readonly IManagementActivityRepository _managementActivityRepository;
+
+ public ManagementActivityService(ClaimsPrincipal user, ILogger logger, IManagementActivityRepository managementActivityRepository)
+ {
+ _user = user;
+ _logger = logger;
+ _managementActivityRepository = managementActivityRepository;
+ }
+
+ public Paged GetPage(ManagementActivityFilter filter, bool? all = false)
+ {
+ _logger.LogInformation("Searching for management files...");
+ _logger.LogDebug("Management file search with filter: {filter}", filter);
+ _user.ThrowIfNotAuthorized(Permissions.ManagementView);
+
+ filter.Page = all.HasValue && all.Value ? 1 : filter.Page;
+ filter.Quantity = all.HasValue && all.Value ? _managementActivityRepository.Count() : filter.Quantity;
+
+ return _managementActivityRepository.GetPageDeep(filter);
+ }
+ }
+}
diff --git a/source/backend/api/Services/ManagementFileService.cs b/source/backend/api/Services/ManagementFileService.cs
new file mode 100644
index 0000000000..d771b7cfd7
--- /dev/null
+++ b/source/backend/api/Services/ManagementFileService.cs
@@ -0,0 +1,422 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
+using Pims.Api.Models.CodeTypes;
+using Pims.Core.Api.Exceptions;
+using Pims.Core.Exceptions;
+using Pims.Core.Extensions;
+using Pims.Core.Security;
+using Pims.Dal.Entities;
+using Pims.Dal.Entities.Models;
+using Pims.Dal.Exceptions;
+using Pims.Dal.Repositories;
+
+namespace Pims.Api.Services
+{
+ public class ManagementFileService : IManagementFileService
+ {
+ private readonly ClaimsPrincipal _user;
+ private readonly ILogger _logger;
+ private readonly IManagementFileRepository _managementFileRepository;
+ private readonly IManagementFilePropertyRepository _managementFilePropertyRepository;
+ private readonly IPropertyRepository _propertyRepository;
+ private readonly IPropertyService _propertyService;
+ private readonly ILookupRepository _lookupRepository;
+ private readonly INoteRelationshipRepository _entityNoteRepository;
+ private readonly IManagementStatusSolver _managementStatusSolver;
+ private readonly IPropertyOperationService _propertyOperationService;
+ private readonly IPropertyActivityRepository _propertyActivityRepository;
+
+ public ManagementFileService(
+ ClaimsPrincipal user,
+ ILogger logger,
+ IManagementFileRepository managementFileRepository,
+ IManagementFilePropertyRepository managementFilePropertyRepository,
+ IPropertyRepository propertyRepository,
+ IPropertyService propertyService,
+ ILookupRepository lookupRepository,
+ INoteRelationshipRepository entityNoteRepository,
+ IManagementStatusSolver managementStatusSolver,
+ IPropertyOperationService propertyOperationService,
+ IPropertyActivityRepository propertyActivityRepository)
+ {
+ _user = user;
+ _logger = logger;
+ _managementFileRepository = managementFileRepository;
+ _managementFilePropertyRepository = managementFilePropertyRepository;
+ _propertyRepository = propertyRepository;
+ _propertyService = propertyService;
+ _lookupRepository = lookupRepository;
+ _entityNoteRepository = entityNoteRepository;
+ _managementStatusSolver = managementStatusSolver;
+ _propertyOperationService = propertyOperationService;
+ _propertyActivityRepository = propertyActivityRepository;
+ }
+
+ public PimsManagementFile Add(PimsManagementFile managementFile, IEnumerable userOverrides)
+ {
+ _logger.LogInformation("Creating management file {managementFile}", managementFile);
+ _user.ThrowIfNotAuthorized(Permissions.ManagementAdd);
+ ArgumentNullException.ThrowIfNull(managementFile);
+
+ ValidateName(managementFile);
+ managementFile.ManagementFileStatusTypeCode ??= ManagementFileStatusTypes.ACTIVE.ToString();
+ ValidateStaff(managementFile);
+
+ MatchProperties(managementFile, userOverrides);
+
+ // Update marker locations in the context of this file
+ foreach (var incomingManagementProperty in managementFile.PimsManagementFileProperties)
+ {
+ _propertyService.PopulateNewFileProperty(incomingManagementProperty);
+ }
+
+ var newManagementFile = _managementFileRepository.Add(managementFile);
+ _managementFileRepository.CommitTransaction();
+
+ return newManagementFile;
+ }
+
+ public PimsManagementFile GetById(long id)
+ {
+ _logger.LogInformation("Getting management file with id {id}", id);
+ _user.ThrowIfNotAuthorized(Permissions.ManagementView);
+
+ var managementFile = _managementFileRepository.GetById(id);
+
+ return managementFile;
+ }
+
+ public PimsManagementFile Update(long id, PimsManagementFile managementFile, IEnumerable userOverrides)
+ {
+ managementFile.ThrowIfNull(nameof(managementFile));
+
+ _logger.LogInformation("Updating management file with id {id}", id);
+ _user.ThrowIfNotAuthorized(Permissions.ManagementEdit);
+
+ if (id != managementFile.ManagementFileId)
+ {
+ throw new BadRequestException("Invalid managementFileId.");
+ }
+
+ ValidateName(managementFile);
+
+ ManagementFileStatusTypes? currentManagementStatus = GetCurrentManagementStatus(managementFile.Internal_Id);
+ if (!_managementStatusSolver.CanEditDetails(currentManagementStatus) && !_user.HasPermission(Permissions.SystemAdmin))
+ {
+ throw new BusinessRuleViolationException("The file you are editing is not active, so you cannot save changes. Refresh your browser to see file state.");
+ }
+
+ ValidateVersion(id, managementFile.ConcurrencyControlNumber);
+
+ // validate management file state before proceeding with any database updates
+ var currentManagementFile = _managementFileRepository.GetById(id);
+ ValidateFileBeforeUpdate(managementFile, currentManagementFile);
+
+ _managementFileRepository.Update(id, managementFile);
+ AddNoteIfStatusChanged(managementFile);
+ _managementFileRepository.CommitTransaction();
+
+ return _managementFileRepository.GetById(id);
+ }
+
+ public LastUpdatedByModel GetLastUpdateInformation(long managementFileId)
+ {
+ _logger.LogInformation("Retrieving last updated-by information...");
+ _user.ThrowIfNotAuthorized(Permissions.ManagementView);
+
+ return _managementFileRepository.GetLastUpdateBy(managementFileId);
+ }
+
+ public IEnumerable GetProperties(long id)
+ {
+ _logger.LogInformation("Getting management file properties with id {id}", id);
+ _user.ThrowIfNotAuthorized(Permissions.ManagementView);
+ _user.ThrowIfNotAuthorized(Permissions.PropertyView);
+
+ var properties = _managementFilePropertyRepository.GetPropertiesByManagementFileId(id);
+ return _propertyService.TransformAllPropertiesToLatLong(properties);
+ }
+
+ public IEnumerable GetTeamMembers()
+ {
+ _logger.LogInformation("Getting management team members");
+ _user.ThrowIfNotAuthorized(Permissions.ManagementView);
+ _user.ThrowIfNotAuthorized(Permissions.ContactView);
+
+ var teamMembers = _managementFileRepository.GetTeamMembers();
+
+ var persons = teamMembers.Where(x => x.Person != null).GroupBy(x => x.PersonId).Select(x => x.First());
+ var organizations = teamMembers.Where(x => x.Organization != null).GroupBy(x => x.OrganizationId).Select(x => x.First());
+
+ List teamFilterOptions = new();
+ teamFilterOptions.AddRange(persons);
+ teamFilterOptions.AddRange(organizations);
+
+ return teamFilterOptions;
+ }
+
+ public PimsManagementFile UpdateProperties(PimsManagementFile managementFile, IEnumerable userOverrides)
+ {
+ _logger.LogInformation("Updating management file properties with ManagementFile id: {id}", managementFile.Internal_Id);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementEdit, Permissions.PropertyView, Permissions.PropertyAdd);
+
+ var currentManagementFile = _managementFileRepository.GetById(managementFile.ManagementFileId);
+ var currentManagementStatus = _managementStatusSolver.GetCurrentManagementStatus(currentManagementFile?.ManagementFileStatusTypeCode);
+ if (!_managementStatusSolver.CanEditProperties(currentManagementStatus))
+ {
+ throw new BusinessRuleViolationException("The file you are editing is not active, so you cannot save changes. Refresh your browser to see file state.");
+ }
+
+ ValidateVersion(managementFile.Internal_Id, managementFile.ConcurrencyControlNumber);
+
+ MatchProperties(managementFile, userOverrides);
+
+ // Get the current properties in the management file
+ var currentFileProperties = _managementFilePropertyRepository.GetPropertiesByManagementFileId(managementFile.Internal_Id);
+
+ // Check if the property is new or if it is being updated
+ foreach (var incomingManagementProperty in managementFile.PimsManagementFileProperties)
+ {
+ var matchingProperty = currentFileProperties.FirstOrDefault(c => c.PropertyId == incomingManagementProperty.PropertyId);
+ if (matchingProperty is not null && incomingManagementProperty.Internal_Id == 0)
+ {
+ incomingManagementProperty.Internal_Id = matchingProperty.Internal_Id;
+ }
+
+ // If the property is not new, check if the name has been updated.
+ if (incomingManagementProperty.Internal_Id != 0)
+ {
+ var needsUpdate = false;
+ PimsManagementFileProperty existingProperty = currentFileProperties.FirstOrDefault(x => x.Internal_Id == incomingManagementProperty.Internal_Id);
+ if (existingProperty.PropertyName != incomingManagementProperty.PropertyName)
+ {
+ existingProperty.PropertyName = incomingManagementProperty.PropertyName;
+ needsUpdate = true;
+ }
+
+ var incomingGeom = incomingManagementProperty.Location;
+ var existingGeom = existingProperty.Location;
+ if (existingGeom is null || (incomingGeom is not null && !existingGeom.EqualsExact(incomingGeom)))
+ {
+ _propertyService.UpdateFilePropertyLocation(incomingManagementProperty, existingProperty);
+ needsUpdate = true;
+ }
+
+ if (needsUpdate)
+ {
+ _managementFilePropertyRepository.Update(existingProperty);
+ }
+ }
+ else
+ {
+ // New property needs to be added
+ var newFileProperty = _propertyService.PopulateNewFileProperty(incomingManagementProperty);
+ _managementFilePropertyRepository.Add(newFileProperty);
+ }
+ }
+
+ IEnumerable fileActivityProperties = _propertyActivityRepository.GetActivitiesByManagementFile(managementFile.Internal_Id).SelectMany(pa => pa.PimsPropPropActivities);
+ // The ones not on the new set should be deleted
+ List differenceSet = currentFileProperties.Where(x => !managementFile.PimsManagementFileProperties.Any(y => y.Internal_Id == x.Internal_Id)).ToList();
+ foreach (var deletedProperty in differenceSet)
+ {
+ if (_propertyOperationService.GetOperationsForProperty(deletedProperty.PropertyId).Count > 0)
+ {
+ throw new BusinessRuleViolationException("This property cannot be deleted because it is part of a subdivision or consolidation");
+ }
+
+ if (fileActivityProperties.Any(ppa => ppa.PropertyId == deletedProperty.PropertyId))
+ {
+ throw new BusinessRuleViolationException("This property cannot be deleted as it is part of an activity in this file");
+ }
+
+ _managementFilePropertyRepository.Delete(deletedProperty);
+
+ var totalAssociationCount = _propertyRepository.GetAllAssociationsCountById(deletedProperty.PropertyId);
+ if (totalAssociationCount <= 1)
+ {
+ _managementFileRepository.CommitTransaction(); // TODO: this can only be removed if cascade deletes are implemented. EF executes deletes in alphabetic order.
+ _propertyRepository.Delete(deletedProperty.Property);
+ }
+ }
+
+ _managementFileRepository.CommitTransaction();
+ return _managementFileRepository.GetById(managementFile.Internal_Id);
+ }
+
+ public Paged GetPage(ManagementFilter filter)
+ {
+ _logger.LogInformation("Searching for management files...");
+ _logger.LogDebug("Management file search with filter: {filter}", filter);
+ _user.ThrowIfNotAuthorized(Permissions.ManagementView);
+
+ return _managementFileRepository.GetPageDeep(filter);
+ }
+
+ private static void ValidateStaff(PimsManagementFile managementFile)
+ {
+ bool duplicate = managementFile.PimsManagementFileTeams.GroupBy(p => $"{p.ManagementFileProfileTypeCode}-O-{p.OrganizationId}-P-{p.PersonId}").Any(g => g.Count() > 1);
+ if (duplicate)
+ {
+ throw new BadRequestException("Invalid Management team, a team member can only be added to a role once.");
+ }
+ }
+
+ private void ValidateName(PimsManagementFile managementFile)
+ {
+ var existingFile = _managementFileRepository.GetByName(managementFile.FileName);
+ if (existingFile != null && managementFile.ManagementFileId != existingFile.ManagementFileId)
+ {
+ throw new BadRequestException("The specified file name already exists. Management File names must be unique, please choose another file name.");
+ }
+ }
+
+ private void ValidateFileBeforeUpdate(PimsManagementFile incomingManagementFile, PimsManagementFile currentManagementFile)
+ {
+ // 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 = currentManagementFile.ManagementFileStatusTypeCode != ManagementFileStatusTypes.COMPLETE.ToString() &&
+ incomingManagementFile.ManagementFileStatusTypeCode == ManagementFileStatusTypes.COMPLETE.ToString();
+
+ var currentProperties = _managementFilePropertyRepository.GetPropertiesByManagementFileId(incomingManagementFile.Internal_Id);
+
+ // The following checks result in hard STOP errors
+ if (isFileClosing && currentProperties.Any(p => !p.Property.IsOwned))
+ {
+ throw new BusinessRuleViolationException("You have one or more properties attached to this Management file that is NOT in the \"Core Inventory\" (i.e. owned by BCTFA and/or HMK). To complete this file you must either, remove these non \"Non-Core Inventory\" properties, OR make sure the property is added to the PIMS inventory first.");
+ }
+
+ ValidateStaff(incomingManagementFile);
+ }
+
+ private void AddNoteIfStatusChanged(PimsManagementFile updateManagementFile)
+ {
+ var currentManagementFile = _managementFileRepository.GetById(updateManagementFile.Internal_Id);
+ bool statusChanged = currentManagementFile.ManagementFileStatusTypeCode != updateManagementFile.ManagementFileStatusTypeCode;
+ if (!statusChanged)
+ {
+ return;
+ }
+
+ var newStatus = _lookupRepository.GetAllManagementFileStatusTypes()
+ .FirstOrDefault(x => x.ManagementFileStatusTypeCode == updateManagementFile.ManagementFileStatusTypeCode);
+
+ PimsManagementFileNote fileNoteInstance = new()
+ {
+ ManagementFileId = updateManagementFile.Internal_Id,
+ AppCreateTimestamp = DateTime.Now,
+ AppCreateUserid = _user.GetUsername(),
+ Note = new PimsNote()
+ {
+ IsSystemGenerated = true,
+ NoteTxt = $"Management File status changed from {currentManagementFile.ManagementFileStatusTypeCodeNavigation.Description} to {newStatus.Description}",
+ AppCreateTimestamp = DateTime.Now,
+ AppCreateUserid = this._user.GetUsername(),
+ },
+ };
+
+ _entityNoteRepository.AddNoteRelationship(fileNoteInstance);
+ }
+
+ private void MatchProperties(PimsManagementFile managementFile, IEnumerable overrideCodes)
+ {
+ foreach (var managementProperty in managementFile.PimsManagementFileProperties)
+ {
+ if (managementProperty.Property.Pid.HasValue)
+ {
+ var pid = managementProperty.Property.Pid.Value;
+ try
+ {
+ var foundProperty = _propertyRepository.GetByPid(pid, true);
+ if (foundProperty.IsRetired.HasValue && foundProperty.IsRetired.Value)
+ {
+ throw new BusinessRuleViolationException("Retired property can not be selected.");
+ }
+
+ managementProperty.PropertyId = foundProperty.Internal_Id;
+ _propertyService.UpdateLocation(managementProperty.Property, ref foundProperty, overrideCodes);
+ managementProperty.Property = foundProperty;
+ }
+ catch (KeyNotFoundException)
+ {
+ if (overrideCodes.Contains(UserOverrideCode.ManagingPropertyNotInventoried))
+ {
+ _logger.LogDebug("Adding new property with pid:{pid}", pid);
+ managementProperty.Property = _propertyService.PopulateNewProperty(managementProperty.Property, false, false);
+ }
+ else
+ {
+ throw new UserOverrideException(UserOverrideCode.ManagingPropertyNotInventoried, "You have added one or more properties to the management file that are not in the MOTI Inventory. To acquire these properties, add them to an acquisition file. Do you want to proceed?");
+ }
+ }
+ }
+ else if (managementProperty.Property.Pin.HasValue)
+ {
+ var pin = managementProperty.Property.Pin.Value;
+ try
+ {
+ var foundProperty = _propertyRepository.GetByPin(pin, true);
+ if (foundProperty.IsRetired.HasValue && foundProperty.IsRetired.Value)
+ {
+ throw new BusinessRuleViolationException("Retired property can not be selected.");
+ }
+
+ managementProperty.PropertyId = foundProperty.Internal_Id;
+ _propertyService.UpdateLocation(managementProperty.Property, ref foundProperty, overrideCodes);
+ managementProperty.Property = foundProperty;
+ }
+ catch (KeyNotFoundException)
+ {
+ if (overrideCodes.Contains(UserOverrideCode.DisposingPropertyNotInventoried))
+ {
+ _logger.LogDebug("Adding new property with pin:{pin}", pin);
+ managementProperty.Property = _propertyService.PopulateNewProperty(managementProperty.Property, false, false);
+ }
+ else
+ {
+ throw new UserOverrideException(UserOverrideCode.DisposingPropertyNotInventoried, "You have added one or more properties to the management file that are not in the MOTI Inventory. To acquire these properties, add them to an acquisition file. Do you want to proceed?");
+ }
+ }
+ }
+ else
+ {
+ if (overrideCodes.Contains(UserOverrideCode.DisposingPropertyNotInventoried))
+ {
+ _logger.LogDebug("Adding new property without a pid");
+ managementProperty.Property = _propertyService.PopulateNewProperty(managementProperty.Property, false, false);
+ }
+ else
+ {
+ throw new UserOverrideException(UserOverrideCode.DisposingPropertyNotInventoried, "You have added one or more properties to the management file that are not in the MOTI Inventory. To acquire these properties, add them to an acquisition file. Do you want to proceed?");
+ }
+ }
+ }
+ }
+
+ private void ValidateVersion(long managementFileId, long managementFileVersion)
+ {
+ long currentRowVersion = _managementFileRepository.GetRowVersion(managementFileId);
+ if (currentRowVersion != managementFileVersion)
+ {
+ throw new DbUpdateConcurrencyException("You are working with an older version of this management file, please refresh the application and retry.");
+ }
+ }
+
+ private ManagementFileStatusTypes? GetCurrentManagementStatus(long managementFileId)
+ {
+ var currentManagementFile = _managementFileRepository.GetById(managementFileId);
+ ManagementFileStatusTypes currentManagementFileStatus;
+
+ if (Enum.TryParse(currentManagementFile.ManagementFileStatusTypeCode, out currentManagementFileStatus))
+ {
+ return currentManagementFileStatus;
+ }
+
+ return currentManagementFileStatus;
+ }
+ }
+}
diff --git a/source/backend/api/Services/NoteService.cs b/source/backend/api/Services/NoteService.cs
index 2e27221339..4741ca0aa3 100644
--- a/source/backend/api/Services/NoteService.cs
+++ b/source/backend/api/Services/NoteService.cs
@@ -1,12 +1,8 @@
using System.Collections.Generic;
-using System.Linq;
using System.Security.Claims;
-using MapsterMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Pims.Api.Constants;
-using Pims.Api.Models.Concepts.Note;
-using Pims.Core.Api.Exceptions;
using Pims.Core.Api.Services;
using Pims.Core.Extensions;
using Pims.Core.Security;
@@ -18,108 +14,134 @@ namespace Pims.Api.Services
public class NoteService : BaseService, INoteService
{
private readonly INoteRepository _noteRepository;
- private readonly IEntityNoteRepository _entityNoteRepository;
- private readonly IMapper _mapper;
+ private readonly INoteRelationshipRepository _acquisitionFileNoteRepository;
+ private readonly INoteRelationshipRepository _dispositionFileNoteRepository;
+ private readonly INoteRelationshipRepository _leaseNoteRepository;
+ private readonly INoteRelationshipRepository _managementFileNoteRepository;
+ private readonly INoteRelationshipRepository _projectNoteRepository;
+ private readonly INoteRelationshipRepository _propertyNoteRepository;
+ private readonly INoteRelationshipRepository _researchFileNoteRepository;
///
/// Creates a new instance of a NoteService, and initializes it with the specified arguments.
///
///
///
- ///
///
- ///
- public NoteService(ClaimsPrincipal user, ILogger logger, IMapper mapper, INoteRepository noteRepository, IEntityNoteRepository entityNoteRepository)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public NoteService(
+ ClaimsPrincipal user,
+ ILogger logger,
+ INoteRepository noteRepository,
+ INoteRelationshipRepository acquisitionFileNoteRepository,
+ INoteRelationshipRepository dispositionFileNoteRepository,
+ INoteRelationshipRepository leaseNoteRepository,
+ INoteRelationshipRepository managementFileNoteRepository,
+ INoteRelationshipRepository projectNoteRepository,
+ INoteRelationshipRepository propertyNoteRepository,
+ INoteRelationshipRepository researchFileNoteRepository)
: base(user, logger)
{
- _mapper = mapper;
_noteRepository = noteRepository;
- _entityNoteRepository = entityNoteRepository;
+ _acquisitionFileNoteRepository = acquisitionFileNoteRepository;
+ _dispositionFileNoteRepository = dispositionFileNoteRepository;
+ _leaseNoteRepository = leaseNoteRepository;
+ _managementFileNoteRepository = managementFileNoteRepository;
+ _projectNoteRepository = projectNoteRepository;
+ _propertyNoteRepository = propertyNoteRepository;
+ _researchFileNoteRepository = researchFileNoteRepository;
}
- public NoteModel GetById(long id)
+ public PimsNote GetById(long id)
{
- this.Logger.LogInformation("Getting note with id {id}", id);
- this.User.ThrowIfNotAuthorized(Permissions.NoteView);
+ Logger.LogInformation("Getting note with id {Id}", id);
+ User.ThrowIfNotAuthorized(Permissions.NoteView);
- var pimsEntity = _noteRepository.GetById(id);
- var noteModel = _mapper.Map(pimsEntity);
-
- return noteModel;
+ return _noteRepository.GetById(id);
}
- public EntityNoteModel Add(NoteType type, EntityNoteModel model)
+ public PimsAcquisitionFileNote AddAcquisitionFileNote(PimsAcquisitionFileNote acquisitionFileNote)
{
- this.Logger.LogInformation("Adding note with type {type} and model {model}", type, model);
- model.ThrowIfNull(nameof(model));
- this.User.ThrowIfNotAuthorized(Permissions.NoteAdd);
+ acquisitionFileNote.ThrowIfNull(nameof(acquisitionFileNote));
+ Logger.LogInformation("Adding note for acquisition file with Id: {Id}", acquisitionFileNote.ParentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteAdd);
- EntityNoteModel result;
+ return AddNoteRelationship(acquisitionFileNote, _acquisitionFileNoteRepository);
+ }
- switch (type)
- {
- case NoteType.Acquisition_File:
- PimsAcquisitionFileNote acqNoteEntity = _mapper.Map(model);
+ public PimsDispositionFileNote AddDispositionFileNote(PimsDispositionFileNote dispositionFileNote)
+ {
+ dispositionFileNote.ThrowIfNull(nameof(dispositionFileNote));
+ Logger.LogInformation("Adding note for disposition file with Id: {Id}", dispositionFileNote.ParentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteAdd);
- PimsAcquisitionFileNote createdAcqEntity = _entityNoteRepository.Add(acqNoteEntity);
- _entityNoteRepository.CommitTransaction();
+ return AddNoteRelationship(dispositionFileNote, _dispositionFileNoteRepository);
+ }
- result = _mapper.Map(createdAcqEntity);
- break;
- case NoteType.Disposition_File:
- PimsDispositionFileNote dispositionNoteEntity = _mapper.Map(model);
+ public PimsLeaseNote AddLeaseNote(PimsLeaseNote leaseNote)
+ {
+ leaseNote.ThrowIfNull(nameof(leaseNote));
+ Logger.LogInformation("Adding note for lease with Id: {Id}", leaseNote.ParentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteAdd);
- PimsDispositionFileNote createdDispositionEntity = _entityNoteRepository.Add(dispositionNoteEntity);
- _entityNoteRepository.CommitTransaction();
+ return AddNoteRelationship(leaseNote, _leaseNoteRepository);
+ }
- result = _mapper.Map(createdDispositionEntity);
- break;
- case NoteType.Lease_File:
- PimsLeaseNote leaseNoteEntity = _mapper.Map(model);
+ public PimsManagementFileNote AddManagementFileNote(PimsManagementFileNote managementFileNote)
+ {
+ managementFileNote.ThrowIfNull(nameof(managementFileNote));
+ Logger.LogInformation("Adding note for management file with Id: {Id}", managementFileNote.ParentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteAdd);
- PimsLeaseNote createdLeaseEntity = _entityNoteRepository.Add(leaseNoteEntity);
- _entityNoteRepository.CommitTransaction();
+ return AddNoteRelationship(managementFileNote, _managementFileNoteRepository);
+ }
- result = _mapper.Map(createdLeaseEntity);
- break;
- case NoteType.Project:
- var projectNote = _mapper.Map(model);
+ public PimsProjectNote AddProjectNote(PimsProjectNote projectNote)
+ {
+ projectNote.ThrowIfNull(nameof(projectNote));
+ Logger.LogInformation("Adding note for project with Id: {Id}", projectNote.ParentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteAdd);
- var createdNote = _entityNoteRepository.Add(projectNote);
- _entityNoteRepository.CommitTransaction();
+ return AddNoteRelationship(projectNote, _projectNoteRepository);
+ }
- result = _mapper.Map(createdNote);
- break;
- case NoteType.Research_File:
- PimsResearchFileNote researchNoteEntity = _mapper.Map(model);
+ public PimsPropertyNote AddPropertyNote(PimsPropertyNote propertyNote)
+ {
+ propertyNote.ThrowIfNull(nameof(propertyNote));
+ Logger.LogInformation("Adding note for property with Id: {Id}", propertyNote.ParentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteAdd);
- PimsResearchFileNote createdResesearchEntity = _entityNoteRepository.Add(researchNoteEntity);
- _entityNoteRepository.CommitTransaction();
+ return AddNoteRelationship(propertyNote, _propertyNoteRepository);
+ }
- result = _mapper.Map(createdResesearchEntity);
- break;
- default:
- throw new BadRequestException("Relationship type not valid.");
- }
+ public PimsResearchFileNote AddResearchFileNote(PimsResearchFileNote researchFileNote)
+ {
+ researchFileNote.ThrowIfNull(nameof(researchFileNote));
+ Logger.LogInformation("Adding note for research file with Id: {Id}", researchFileNote.ParentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteAdd);
- return result;
+ return AddNoteRelationship(researchFileNote, _researchFileNoteRepository);
}
- public NoteModel Update(NoteModel model)
+ public PimsNote Update(PimsNote note)
{
- model.ThrowIfNull(nameof(model));
+ note.ThrowIfNull(nameof(note));
+ Logger.LogInformation("Updating note with id {Id}", note.Internal_Id);
+ User.ThrowIfNotAuthorized(Permissions.NoteEdit);
- this.Logger.LogInformation("Updating note with id {id}", model.Id);
- this.User.ThrowIfNotAuthorized(Permissions.NoteEdit);
+ ValidateVersion(note.Internal_Id, note.ConcurrencyControlNumber);
- ValidateVersion(model.Id, model.RowVersion);
-
- var pimsEntity = _mapper.Map(model);
- var newNote = _noteRepository.Update(pimsEntity);
+ var updatedNote = _noteRepository.Update(note);
_noteRepository.CommitTransaction();
- this.Logger.LogInformation("Note with id {id} update successfully", model.Id);
- return GetById(newNote.Internal_Id);
+ Logger.LogInformation("Note with id {Id} updated successfully", note.Internal_Id);
+ return GetById(updatedNote.Internal_Id);
}
///
@@ -130,23 +152,25 @@ public NoteModel Update(NoteModel model)
/// Whether or not this transaction should be commited as part of this function.
public bool DeleteNote(NoteType type, long noteId, bool commitTransaction = true)
{
- this.Logger.LogInformation("Deleting note with type {type} and id {noteId}", type, noteId);
- this.User.ThrowIfNotAuthorized(Permissions.NoteDelete);
+ Logger.LogInformation("Deleting note with type {Type} and id {NoteId}", type, noteId);
+ User.ThrowIfNotAuthorized(Permissions.NoteDelete);
bool deleted = false;
deleted = type switch
{
- NoteType.Acquisition_File => _entityNoteRepository.DeleteAcquisitionFileNotes(noteId),
- NoteType.Disposition_File => _entityNoteRepository.DeleteDispositionFileNotes(noteId),
- NoteType.Project => _entityNoteRepository.DeleteProjectNotes(noteId),
- NoteType.Lease_File => _entityNoteRepository.DeleteLeaseFileNotes(noteId),
- NoteType.Research_File => _entityNoteRepository.DeleteResearchNotes(noteId),
+ NoteType.Acquisition_File => _acquisitionFileNoteRepository.DeleteNoteRelationship(noteId),
+ NoteType.Disposition_File => _dispositionFileNoteRepository.DeleteNoteRelationship(noteId),
+ NoteType.Project => _projectNoteRepository.DeleteNoteRelationship(noteId),
+ NoteType.Lease_File => _leaseNoteRepository.DeleteNoteRelationship(noteId),
+ NoteType.Research_File => _researchFileNoteRepository.DeleteNoteRelationship(noteId),
+ NoteType.Management_File => _managementFileNoteRepository.DeleteNoteRelationship(noteId),
+ NoteType.Property => _propertyNoteRepository.DeleteNoteRelationship(noteId),
_ => deleted
};
if (commitTransaction)
{
- _entityNoteRepository.CommitTransaction();
+ _noteRepository.CommitTransaction();
}
return deleted;
@@ -156,26 +180,37 @@ public bool DeleteNote(NoteType type, long noteId, bool commitTransaction = true
/// Get notes by note type.
///
/// Note type to determine the type of notes to return.
- /// Entity Id to determine the entity to which notes belongs to.
+ /// Entity Id to determine the entity to which notes belongs to.
///
- public IEnumerable GetNotes(NoteType type, long entityId)
+ public IEnumerable GetNotes(NoteType type, long parentId)
{
- this.Logger.LogInformation($"Getting all notes with type {type} and parent id {entityId}");
- this.User.ThrowIfNotAuthorized(Permissions.NoteView);
+ Logger.LogInformation("Getting all notes with type {Type} and parent id {EntityId}", type, parentId);
+ User.ThrowIfNotAuthorized(Permissions.NoteView);
- List notes = type switch
+ IList notes = type switch
{
- NoteType.Acquisition_File => _entityNoteRepository.GetAllAcquisitionNotesById(entityId).ToList(),
- NoteType.Disposition_File => _entityNoteRepository.GetAllDispositionNotesById(entityId).ToList(),
- NoteType.Project => _entityNoteRepository.GetAllProjectNotesById(entityId).ToList(),
- NoteType.Lease_File => _entityNoteRepository.GetAllLeaseNotesById(entityId).ToList(),
- NoteType.Research_File => _entityNoteRepository.GetAllResearchNotesById(entityId).ToList(),
+ NoteType.Acquisition_File => _acquisitionFileNoteRepository.GetAllByParentId(parentId),
+ NoteType.Disposition_File => _dispositionFileNoteRepository.GetAllByParentId(parentId),
+ NoteType.Project => _projectNoteRepository.GetAllByParentId(parentId),
+ NoteType.Lease_File => _leaseNoteRepository.GetAllByParentId(parentId),
+ NoteType.Research_File => _researchFileNoteRepository.GetAllByParentId(parentId),
+ NoteType.Management_File => _managementFileNoteRepository.GetAllByParentId(parentId),
+ NoteType.Property => _propertyNoteRepository.GetAllByParentId(parentId),
_ => new List()
};
return notes;
}
+ private static T AddNoteRelationship(T noteRelationship, INoteRelationshipRepository noteRelationshipRepository)
+ where T : PimsNoteRelationship, new()
+ {
+ T newEntity = noteRelationshipRepository.AddNoteRelationship(noteRelationship);
+ noteRelationshipRepository.CommitTransaction();
+
+ return newEntity;
+ }
+
private void ValidateVersion(long noteId, long? noteVersion)
{
long currentRowVersion = _noteRepository.GetRowVersion(noteId);
diff --git a/source/backend/api/Services/ProjectService.cs b/source/backend/api/Services/ProjectService.cs
index bb6e0019e4..afb8e90338 100644
--- a/source/backend/api/Services/ProjectService.cs
+++ b/source/backend/api/Services/ProjectService.cs
@@ -24,7 +24,7 @@ public class ProjectService : BaseService, IProjectService
private readonly IAcquisitionFileRepository _acquisitionFileRepository;
private readonly IUserRepository _userRepository;
private readonly ILookupRepository _lookupRepository;
- private readonly IEntityNoteRepository _entityNoteRepository;
+ private readonly INoteRelationshipRepository _entityNoteRepository;
private readonly ClaimsPrincipal _user;
///
@@ -46,7 +46,7 @@ public ProjectService(
IAcquisitionFileRepository acquisitionFileRepository,
IUserRepository userRepository,
ILookupRepository lookupRepository,
- IEntityNoteRepository entityNoteRepository)
+ INoteRelationshipRepository entityNoteRepository)
: base(user, logger)
{
_logger = logger;
@@ -286,7 +286,7 @@ private void AddNoteIfStatusChanged(PimsProject updatedProject)
},
};
- _entityNoteRepository.Add(projectNoteInstance);
+ _entityNoteRepository.AddNoteRelationship(projectNoteInstance);
}
private string GetUpdatedNoteText(string oldStatusCode, string newStatusCode)
diff --git a/source/backend/api/Services/PropertyService.cs b/source/backend/api/Services/PropertyService.cs
index 058452f41b..791619b909 100644
--- a/source/backend/api/Services/PropertyService.cs
+++ b/source/backend/api/Services/PropertyService.cs
@@ -216,51 +216,6 @@ public PropertyManagementModel GetPropertyManagement(long propertyId)
return propertyManagement;
}
- private static void PropertyHasActiveLease(IEnumerable propertyLeases, out bool hasActiveLease, out bool hasActiveExpiryDate)
- {
- hasActiveLease = false;
- hasActiveExpiryDate = false;
-
- List activeLeaseList = propertyLeases.Select(x => x.Lease).Where(y => y.LeaseStatusTypeCode == LeaseStatusTypes.ACTIVE.ToString()).ToList();
- foreach (var agreement in activeLeaseList)
- {
- if (!agreement.TerminationDate.HasValue)
- {
- var latestRenewal = agreement.PimsLeaseRenewals.Where(x => x.IsExercised == true).OrderByDescending(x => x.CommencementDt).FirstOrDefault();
- if (latestRenewal is null) // No Renewal - Check only Lease dates.
- {
- if (agreement.OrigExpiryDate.HasValue && agreement.OrigExpiryDate.Value.Date >= DateTime.Now.Date)
- {
- hasActiveLease = hasActiveExpiryDate = true;
- }
- else if (!agreement.OrigExpiryDate.HasValue)
- {
- hasActiveLease = true;
- }
- }
- else
- {
- if (agreement.OrigExpiryDate.HasValue && latestRenewal.ExpiryDt.HasValue)
- {
- hasActiveLease = hasActiveExpiryDate = agreement.OrigExpiryDate.Value.Date >= DateTime.Now.Date || latestRenewal.ExpiryDt.Value.Date >= DateTime.Now.Date;
- }
- else if (agreement.OrigExpiryDate.HasValue && !latestRenewal.ExpiryDt.HasValue)
- {
- hasActiveLease = true;
- }
- else if (!agreement.OrigExpiryDate.HasValue && latestRenewal.ExpiryDt.HasValue)
- {
- hasActiveLease = latestRenewal.ExpiryDt.Value.Date >= DateTime.Now.Date;
- }
- else
- {
- hasActiveLease = true;
- }
- }
- }
- }
- }
-
public PropertyManagementModel UpdatePropertyManagement(PimsProperty property)
{
_logger.LogInformation("Updating property management information...");
@@ -276,30 +231,41 @@ public PropertyManagementModel UpdatePropertyManagement(PimsProperty property)
public IList GetActivities(long propertyId)
{
_logger.LogInformation("Getting property management activities for property with id {propertyId}", propertyId);
- _user.ThrowIfNotAuthorized(Permissions.ManagementView, Permissions.PropertyView);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementView, Permissions.PropertyView);
return _propertyActivityRepository.GetActivitiesByProperty(propertyId);
}
- public PimsPropertyActivity GetActivity(long propertyId, long activityId)
+ public IList GetFileActivities(long managementFileId)
{
- _logger.LogInformation("Retrieving single property Activity...");
- _user.ThrowIfNotAuthorized(Permissions.ManagementView, Permissions.PropertyView);
+ _logger.LogInformation("Getting property management activities for management file with id {managementFileId}", managementFileId);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementView, Permissions.PropertyView);
- var propertyActivity = _propertyActivityRepository.GetActivity(activityId);
+ return _propertyActivityRepository.GetActivitiesByManagementFile(managementFileId);
+ }
- if (propertyActivity.PimsPropPropActivities.Any(x => x.PropertyId == propertyId))
- {
- return propertyActivity;
- }
+ public PimsPropertyActivity GetActivity(long activityId)
+ {
+ _logger.LogInformation("Retrieving property Activity with Id: {ActivityId}", activityId);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementView, Permissions.PropertyView);
- throw new BadRequestException("Activity with the given id does not match the property id");
+ return _propertyActivityRepository.GetActivity(activityId);
+ }
+
+ public IEnumerable GetActivitiesByPropertyIds(IEnumerable propertyIds)
+ {
+ _logger.LogInformation("Retrieving multiple property Activities... {propertyIds}", propertyIds);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementView, Permissions.PropertyView);
+
+ var managementFilePropertyIds = _propertyActivityRepository.GetActivitiesByPropertyIds(propertyIds);
+
+ return managementFilePropertyIds;
}
public PimsPropertyActivity CreateActivity(PimsPropertyActivity propertyActivity)
{
_logger.LogInformation("Creating property Activity...");
- _user.ThrowIfNotAuthorized(Permissions.ManagementAdd, Permissions.PropertyEdit);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementAdd, Permissions.PropertyEdit);
if (propertyActivity.PropMgmtActivityStatusTypeCode == null)
{
@@ -312,16 +278,11 @@ public PimsPropertyActivity CreateActivity(PimsPropertyActivity propertyActivity
return propertyActivityResult;
}
- public PimsPropertyActivity UpdateActivity(long propertyId, long activityId, PimsPropertyActivity propertyActivity)
+ public PimsPropertyActivity UpdateActivity(PimsPropertyActivity propertyActivity)
{
- _logger.LogInformation("Updating property Activity...");
- _user.ThrowIfNotAuthorized(Permissions.ManagementEdit, Permissions.PropertyEdit);
-
- if (!propertyActivity.PimsPropPropActivities.Any(x => x.PropertyId == propertyId && x.PimsPropertyActivityId == activityId)
- || propertyActivity.PimsPropertyActivityId != activityId)
- {
- throw new BadRequestException("Invalid activity identifiers.");
- }
+ propertyActivity.ThrowIfNull(nameof(propertyActivity));
+ _logger.LogInformation("Updating property Activity with Id: {ActivityId}", propertyActivity.Internal_Id);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementEdit, Permissions.PropertyEdit);
var propertyActivityResult = _propertyActivityRepository.Update(propertyActivity);
_propertyActivityRepository.CommitTransaction();
@@ -329,10 +290,33 @@ public PimsPropertyActivity UpdateActivity(long propertyId, long activityId, Pim
return propertyActivityResult;
}
+ public bool DeleteFileActivity(long managementFileId, long activityId)
+ {
+ _logger.LogInformation("Deleting Management Activity with id {activityId}", activityId);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementDelete, Permissions.PropertyEdit);
+
+ var propertyManagementActivity = _propertyActivityRepository.GetActivity(activityId);
+
+ if (propertyManagementActivity.ManagementFileId != managementFileId)
+ {
+ throw new BadRequestException("Activity with the given id does not match the management file id");
+ }
+
+ if (!propertyManagementActivity.PropMgmtActivityStatusTypeCode.Equals(PropertyActivityStatusTypeCode.NOTSTARTED.ToString()))
+ {
+ throw new BadRequestException($"PropertyManagementActivity can not be deleted since it has already started");
+ }
+
+ var success = _propertyActivityRepository.TryDeleteByFile(activityId, managementFileId);
+ _propertyRepository.CommitTransaction();
+
+ return success;
+ }
+
public bool DeleteActivity(long activityId)
{
_logger.LogInformation("Deleting Management Activity with id {activityId}", activityId);
- _user.ThrowIfNotAuthorized(Permissions.ManagementDelete, Permissions.PropertyEdit);
+ _user.ThrowIfNotAllAuthorized(Permissions.ManagementDelete, Permissions.PropertyEdit);
var propertyManagementActivity = _propertyActivityRepository.GetActivity(activityId);
@@ -520,6 +504,51 @@ public PimsProperty TransformPropertyToLatLong(PimsProperty property)
return property;
}
+ private static void PropertyHasActiveLease(IEnumerable propertyLeases, out bool hasActiveLease, out bool hasActiveExpiryDate)
+ {
+ hasActiveLease = false;
+ hasActiveExpiryDate = false;
+
+ List activeLeaseList = propertyLeases.Select(x => x.Lease).Where(y => y.LeaseStatusTypeCode == LeaseStatusTypes.ACTIVE.ToString()).ToList();
+ foreach (var agreement in activeLeaseList)
+ {
+ if (!agreement.TerminationDate.HasValue)
+ {
+ var latestRenewal = agreement.PimsLeaseRenewals.Where(x => x.IsExercised == true).OrderByDescending(x => x.CommencementDt).FirstOrDefault();
+ if (latestRenewal is null) // No Renewal - Check only Lease dates.
+ {
+ if (agreement.OrigExpiryDate.HasValue && agreement.OrigExpiryDate.Value.Date >= DateTime.Now.Date)
+ {
+ hasActiveLease = hasActiveExpiryDate = true;
+ }
+ else if (!agreement.OrigExpiryDate.HasValue)
+ {
+ hasActiveLease = true;
+ }
+ }
+ else
+ {
+ if (agreement.OrigExpiryDate.HasValue && latestRenewal.ExpiryDt.HasValue)
+ {
+ hasActiveLease = hasActiveExpiryDate = agreement.OrigExpiryDate.Value.Date >= DateTime.Now.Date || latestRenewal.ExpiryDt.Value.Date >= DateTime.Now.Date;
+ }
+ else if (agreement.OrigExpiryDate.HasValue && !latestRenewal.ExpiryDt.HasValue)
+ {
+ hasActiveLease = true;
+ }
+ else if (!agreement.OrigExpiryDate.HasValue && latestRenewal.ExpiryDt.HasValue)
+ {
+ hasActiveLease = latestRenewal.ExpiryDt.Value.Date >= DateTime.Now.Date;
+ }
+ else
+ {
+ hasActiveLease = true;
+ }
+ }
+ }
+ }
+ }
+
private Point TransformCoordinates(Geometry location)
{
// return property spatial location in lat/long (4326)
diff --git a/source/backend/api/Services/ResearchFileService.cs b/source/backend/api/Services/ResearchFileService.cs
index b4308a32ca..6a7c0e8526 100644
--- a/source/backend/api/Services/ResearchFileService.cs
+++ b/source/backend/api/Services/ResearchFileService.cs
@@ -22,7 +22,7 @@ public class ResearchFileService : IResearchFileService
private readonly IResearchFilePropertyRepository _researchFilePropertyRepository;
private readonly IPropertyRepository _propertyRepository;
private readonly ILookupRepository _lookupRepository;
- private readonly IEntityNoteRepository _entityNoteRepository;
+ private readonly INoteRelationshipRepository _entityNoteRepository;
private readonly IPropertyService _propertyService;
private readonly IPropertyOperationService _propertyOperationService;
private readonly IResearchStatusSolver _researchStatusSolver;
@@ -34,7 +34,7 @@ public ResearchFileService(
IResearchFilePropertyRepository researchFilePropertyRepository,
IPropertyRepository propertyRepository,
ILookupRepository lookupRepository,
- IEntityNoteRepository entityNoteRepository,
+ INoteRelationshipRepository entityNoteRepository,
IPropertyService propertyService,
IPropertyOperationService propertyOperationService,
IResearchStatusSolver researchStatusSolver)
@@ -309,7 +309,7 @@ private void AddNoteIfStatusChanged(PimsResearchFile updateResearchFile)
},
};
- _entityNoteRepository.Add(fileNoteInstance);
+ _entityNoteRepository.AddNoteRelationship(fileNoteInstance);
}
}
}
diff --git a/source/backend/api/Services/TakeService.cs b/source/backend/api/Services/TakeService.cs
index f860c71873..e0202b1d55 100644
--- a/source/backend/api/Services/TakeService.cs
+++ b/source/backend/api/Services/TakeService.cs
@@ -5,11 +5,11 @@
using Microsoft.Extensions.Logging;
using Pims.Api.Models.CodeTypes;
using Pims.Core.Exceptions;
+using Pims.Core.Extensions;
+using Pims.Core.Security;
using Pims.Dal.Entities;
using Pims.Dal.Exceptions;
-using Pims.Core.Extensions;
using Pims.Dal.Repositories;
-using Pims.Core.Security;
namespace Pims.Api.Services
{
diff --git a/source/backend/api/Solvers/IManagementStatusSolver.cs b/source/backend/api/Solvers/IManagementStatusSolver.cs
new file mode 100644
index 0000000000..4fb3e00007
--- /dev/null
+++ b/source/backend/api/Solvers/IManagementStatusSolver.cs
@@ -0,0 +1,13 @@
+using Pims.Api.Models.CodeTypes;
+
+namespace Pims.Api.Services
+{
+ public interface IManagementStatusSolver
+ {
+ bool CanEditDetails(ManagementFileStatusTypes? managementStatus);
+
+ bool CanEditProperties(ManagementFileStatusTypes? managementStatus);
+
+ ManagementFileStatusTypes? GetCurrentManagementStatus(string pimsManagementStatusType);
+ }
+}
diff --git a/source/backend/api/Solvers/ManagementStatusSolver.cs b/source/backend/api/Solvers/ManagementStatusSolver.cs
new file mode 100644
index 0000000000..05791976e8
--- /dev/null
+++ b/source/backend/api/Solvers/ManagementStatusSolver.cs
@@ -0,0 +1,77 @@
+using System;
+using Pims.Api.Models.CodeTypes;
+
+namespace Pims.Api.Services
+{
+ public class ManagementStatusSolver : IManagementStatusSolver
+ {
+ public bool CanEditDetails(ManagementFileStatusTypes? managementStatus)
+ {
+ if (managementStatus == null)
+ {
+ return false;
+ }
+
+ bool canEdit;
+ switch (managementStatus)
+ {
+ case ManagementFileStatusTypes.ACTIVE:
+ case ManagementFileStatusTypes.DRAFT:
+ case ManagementFileStatusTypes.HOLD:
+ case ManagementFileStatusTypes.THIRDRDPARTY:
+ canEdit = true;
+ break;
+ case ManagementFileStatusTypes.ARCHIVED:
+ case ManagementFileStatusTypes.CANCELLED:
+ case ManagementFileStatusTypes.COMPLETE:
+ canEdit = false;
+ break;
+ default:
+ canEdit = false;
+ break;
+ }
+
+ return canEdit;
+ }
+
+ public bool CanEditProperties(ManagementFileStatusTypes? managementStatus)
+ {
+ if (managementStatus == null)
+ {
+ return false;
+ }
+
+ bool canEdit;
+ switch (managementStatus)
+ {
+ case ManagementFileStatusTypes.ACTIVE:
+ case ManagementFileStatusTypes.DRAFT:
+ case ManagementFileStatusTypes.HOLD:
+ case ManagementFileStatusTypes.THIRDRDPARTY:
+ canEdit = true;
+ break;
+ case ManagementFileStatusTypes.ARCHIVED:
+ case ManagementFileStatusTypes.CANCELLED:
+ case ManagementFileStatusTypes.COMPLETE:
+ canEdit = false;
+ break;
+ default:
+ canEdit = false;
+ break;
+ }
+
+ return canEdit;
+ }
+
+ public ManagementFileStatusTypes? GetCurrentManagementStatus(string pimsManagementStatusType)
+ {
+ ManagementFileStatusTypes currentManagementStatus;
+ if (Enum.TryParse(pimsManagementStatusType, out currentManagementStatus))
+ {
+ return currentManagementStatus;
+ }
+
+ return currentManagementStatus;
+ }
+ }
+}
diff --git a/source/backend/api/Startup.cs b/source/backend/api/Startup.cs
index 0b5e00765d..2128243d3a 100644
--- a/source/backend/api/Startup.cs
+++ b/source/backend/api/Startup.cs
@@ -12,6 +12,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
+using DotNetEnv;
using HealthChecks.SqlServer;
using HealthChecks.UI.Client;
using Mapster;
@@ -56,8 +57,6 @@
using Pims.Ltsa;
using Polly;
using Prometheus;
-using DotNetEnv;
-using Microsoft.IdentityModel.JsonWebTokens;
namespace Pims.Api
{
@@ -565,6 +564,9 @@ private static void AddPimsApiServices(IServiceCollection services)
services.AddScoped();
services.AddScoped();
services.AddScoped();
+ services.AddScoped();
+ services.AddScoped();
+ services.AddScoped();
}
///
diff --git a/source/backend/apimodels/CodeTypes/DocumentRelationType.cs b/source/backend/apimodels/CodeTypes/DocumentRelationType.cs
index fba970499d..7b748c2e46 100644
--- a/source/backend/apimodels/CodeTypes/DocumentRelationType.cs
+++ b/source/backend/apimodels/CodeTypes/DocumentRelationType.cs
@@ -16,9 +16,13 @@ public enum DocumentRelationType
Leases,
[EnumMember(Value = "Projects")]
Projects,
+ [EnumMember(Value = "ManagementActivities")]
+ ManagementActivities,
[EnumMember(Value = "ManagementFiles")]
ManagementFiles,
[EnumMember(Value = "DispositionFiles")]
DispositionFiles,
+ [EnumMember(Value = "Properties")]
+ Properties,
}
}
diff --git a/source/backend/apimodels/CodeTypes/FileTypes.cs b/source/backend/apimodels/CodeTypes/FileTypes.cs
index 5336a89e32..9c036b18df 100644
--- a/source/backend/apimodels/CodeTypes/FileTypes.cs
+++ b/source/backend/apimodels/CodeTypes/FileTypes.cs
@@ -15,5 +15,8 @@ public enum FileTypes
[EnumMember(Value = "lease")]
Lease,
+
+ [EnumMember(Value = "management")]
+ Management,
}
}
diff --git a/source/backend/apimodels/CodeTypes/ManagementActivityStatusTypes.cs b/source/backend/apimodels/CodeTypes/ManagementActivityStatusTypes.cs
new file mode 100644
index 0000000000..97353386cf
--- /dev/null
+++ b/source/backend/apimodels/CodeTypes/ManagementActivityStatusTypes.cs
@@ -0,0 +1,24 @@
+using System.Runtime.Serialization;
+using System.Text.Json.Serialization;
+
+namespace Pims.Api.Models.CodeTypes
+{
+ [JsonConverter(typeof(JsonStringEnumMemberConverter))]
+ public enum ManagementActivityStatusTypes
+ {
+ [EnumMember(Value = "CANCELLED")]
+ CANCELLED,
+
+ [EnumMember(Value = "COMPLETED")]
+ COMPLETED,
+
+ [EnumMember(Value = "INPROGRESS")]
+ INPROGRESS,
+
+ [EnumMember(Value = "NOTSTARTED")]
+ NOTSTARTED,
+
+ [EnumMember(Value = "ONHOLD")]
+ ONHOLD,
+ }
+}
diff --git a/source/backend/apimodels/CodeTypes/ManagementFilePurposeTypes.cs b/source/backend/apimodels/CodeTypes/ManagementFilePurposeTypes.cs
new file mode 100644
index 0000000000..d6d0615e64
--- /dev/null
+++ b/source/backend/apimodels/CodeTypes/ManagementFilePurposeTypes.cs
@@ -0,0 +1,42 @@
+using System.Runtime.Serialization;
+using System.Text.Json.Serialization;
+
+namespace Pims.Api.Models.CodeTypes
+{
+ [JsonConverter(typeof(JsonStringEnumMemberConverter))]
+ public enum ManagementFilePurposeTypes
+ {
+ [EnumMember(Value = "AGRICULT")]
+ AGRICULT,
+ [EnumMember(Value = "BCFERRY")]
+ BCFERRY,
+ [EnumMember(Value = "BCTRANS")]
+ BCTRANS,
+ [EnumMember(Value = "COMMBLDG")]
+ COMMBLDG,
+ [EnumMember(Value = "ENCAMP")]
+ ENCAMP,
+ [EnumMember(Value = "ENGINEER")]
+ ENGINEER,
+ [EnumMember(Value = "GENERAL")]
+ GENERAL,
+ [EnumMember(Value = "GOVERNMT")]
+ GOVERNMT,
+ [EnumMember(Value = "MOTTUSE")]
+ MOTTUSE,
+ [EnumMember(Value = "OILGAS")]
+ OILGAS,
+ [EnumMember(Value = "OTHER")]
+ OTHER,
+ [EnumMember(Value = "PARKING")]
+ PARKING,
+ [EnumMember(Value = "RAIL")]
+ RAIL,
+ [EnumMember(Value = "RESRENTL")]
+ RESRENTL,
+ [EnumMember(Value = "TRAILS")]
+ TRAILS,
+ [EnumMember(Value = "UTILITY")]
+ UTILITY,
+ }
+}
diff --git a/source/backend/apimodels/CodeTypes/ManagementFileStatusTypes.cs b/source/backend/apimodels/CodeTypes/ManagementFileStatusTypes.cs
new file mode 100644
index 0000000000..d289059449
--- /dev/null
+++ b/source/backend/apimodels/CodeTypes/ManagementFileStatusTypes.cs
@@ -0,0 +1,30 @@
+using System.Runtime.Serialization;
+using System.Text.Json.Serialization;
+
+namespace Pims.Api.Models.CodeTypes
+{
+ [JsonConverter(typeof(JsonStringEnumMemberConverter))]
+ public enum ManagementFileStatusTypes
+ {
+ [EnumMember(Value = "ACTIVE")]
+ ACTIVE,
+
+ [EnumMember(Value = "ARCHIVED")]
+ ARCHIVED,
+
+ [EnumMember(Value = "CANCELLED")]
+ CANCELLED,
+
+ [EnumMember(Value = "COMPLETE")]
+ COMPLETE,
+
+ [EnumMember(Value = "DRAFT")]
+ DRAFT,
+
+ [EnumMember(Value = "HOLD")]
+ HOLD,
+
+ [EnumMember(Value = "3RDPARTY")]
+ THIRDRDPARTY,
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs
index b4a1f3ed87..38f4e5ac4b 100644
--- a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs
+++ b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs
@@ -87,6 +87,33 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.PimsInterestHolders, src => src.AcquisitionFileInterestHolders)
.Map(dest => dest.PimsAcquisitionChecklistItems, src => src.FileChecklistItems)
.Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
+ .Map(dest => dest.PrntAcquisitionFileId, src => src.PrntAcquisitionFileId)
+ .Map(dest => dest.FileNo, src => src.FileNo)
+ .Map(dest => dest.FileNoSuffix, src => src.FileNoSuffix)
+ .Map(dest => dest.FileName, src => src.FileName)
+ .Map(dest => dest.LegacyFileNumber, src => src.LegacyFileNumber)
+ .Map(dest => dest.ProjectId, src => src.ProjectId)
+ .Map(dest => dest.ProductId, src => src.ProductId)
+ .Map(dest => dest.AcquisitionFundingTypeCode, src => src.AcquisitionFundingTypeCode)
+ .Map(dest => dest.FundingOther, src => src.FundingOther)
+ .Map(dest => dest.AssignedDate, src => src.AssignedDate)
+ .Map(dest => dest.DeliveryDate, src => src.DeliveryDate)
+ .Map(dest => dest.EstCompletionDt, src => src.EstCompletionDt)
+ .Map(dest => dest.PossessionDt, src => src.PossessionDt)
+ .Map(dest => dest.AcqFileAppraisalTypeCode, src => src.AcqFileAppraisalTypeCode)
+ .Map(dest => dest.AcqFileLglSrvyTypeCode, src => src.AcqFileLglSrvyTypeCode)
+ .Map(dest => dest.AcqFileExpropRiskTypeCode, src => src.AcqFileExpropRiskTypeCode)
+ .Map(dest => dest.TotalAllowableCompensation, src => src.TotalAllowableCompensation)
+ .Map(dest => dest.AcquisitionFileStatusTypeCode, src => src.AcquisitionFileStatusTypeCode)
+ .Map(dest => dest.AcqPhysFileStatusTypeCode, src => src.AcqPhysFileStatusTypeCode)
+ .Map(dest => dest.PhysicalFileDetails, src => src.PhysicalFileDetails)
+ .Map(dest => dest.AcquisitionTypeCode, src => src.AcquisitionTypeCode)
+ .Map(dest => dest.RegionCode, src => src.RegionCode)
+ .Map(dest => dest.SubfileInterestTypeCode, src => src.SubfileInterestTypeCode)
+ .Map(dest => dest.OtherSubfileInterestType, src => src.OtherSubfileInterestType);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileOwnerMap.cs b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileOwnerMap.cs
index 1951bf52cf..6de53bb67f 100644
--- a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileOwnerMap.cs
+++ b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileOwnerMap.cs
@@ -7,7 +7,8 @@ public class AcquisitionFileOwnerMap : IRegister
{
public void Register(TypeAdapterConfig config)
{
- config.NewConfig()
+ config
+ .NewConfig()
.Map(dest => dest.Id, src => src.AcquisitionOwnerId)
.Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
.Map(dest => dest.RowVersion, src => src.ConcurrencyControlNumber)
@@ -22,7 +23,8 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.RegistrationNumber, src => src.RegistrationNumber)
.Map(dest => dest.Address, src => src.Address);
- config.NewConfig()
+ config
+ .NewConfig()
.Map(dest => dest.AcquisitionOwnerId, src => src.Id)
.Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
.Map(dest => dest.ConcurrencyControlNumber, src => src.RowVersion)
@@ -37,6 +39,21 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.RegistrationNumber, src => src.RegistrationNumber)
.Map(dest => dest.AddressId, src => src.Address.Id)
.Map(dest => dest.Address, src => src.Address);
+
+ config
+ .NewConfig()
+ .Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId)
+ .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
+ .Map(dest => dest.IsPrimaryOwner, src => src.IsPrimaryOwner)
+ .Map(dest => dest.IsOrganization, src => src.IsOrganization)
+ .Map(dest => dest.LastNameAndCorpName, src => src.LastNameAndCorpName)
+ .Map(dest => dest.OtherName, src => src.OtherName)
+ .Map(dest => dest.GivenName, src => src.GivenName)
+ .Map(dest => dest.ContactEmailAddr, src => src.ContactEmailAddr)
+ .Map(dest => dest.ContactPhoneNum, src => src.ContactPhoneNum)
+ .Map(dest => dest.IncorporationNumber, src => src.IncorporationNumber)
+ .Map(dest => dest.RegistrationNumber, src => src.RegistrationNumber)
+ .Map(dest => dest.AddressId, src => src.AddressId);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFilePropertyMap.cs b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFilePropertyMap.cs
index 7b13a6d484..dbea301a94 100644
--- a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFilePropertyMap.cs
+++ b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFilePropertyMap.cs
@@ -30,6 +30,14 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
.Map(dest => dest.Location, src => src.Location)
.Inherits();
+
+ config.NewConfig()
+ .PreserveReference(true)
+ .Map(dest => dest.PropertyAcquisitionFileId, src => src.PropertyAcquisitionFileId)
+ .Map(dest => dest.PropertyId, src => src.PropertyId)
+ .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
+ .Map(dest => dest.PropertyName, src => src.PropertyName)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTakingStatusesMap.cs b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTakingStatusesMap.cs
index 6124c5f053..d2e1339d3c 100644
--- a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTakingStatusesMap.cs
+++ b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTakingStatusesMap.cs
@@ -8,7 +8,7 @@ public class AcquisitionFileTakingStatusesMap : IRegister
{
public void Register(TypeAdapterConfig config)
{
- config.NewConfig ()
+ config.NewConfig()
.Map(dest => dest.Id, src => src.AcqFileAcqFlTakeTypeId)
.Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
.Map(dest => dest.TakingStatusTypeCode, src => src.AcqFileTakeTypeCodeNavigation)
diff --git a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTeamMap.cs b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTeamMap.cs
index 5a8c724cb4..eef3e78388 100644
--- a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTeamMap.cs
+++ b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileTeamMap.cs
@@ -29,6 +29,14 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
.Map(dest => dest.AcqFlTeamProfileTypeCode, src => src.TeamProfileTypeCode)
.Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.AcquisitionFileTeamId, src => src.AcquisitionFileTeamId)
+ .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
+ .Map(dest => dest.PersonId, src => src.PersonId)
+ .Map(dest => dest.OrganizationId, src => src.OrganizationId)
+ .Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
+ .Map(dest => dest.AcqFlTeamProfileTypeCode, src => src.AcqFlTeamProfileTypeCode);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqAcqPayeeMap.cs b/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqAcqPayeeMap.cs
index d966c84f96..a08b63f474 100644
--- a/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqAcqPayeeMap.cs
+++ b/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqAcqPayeeMap.cs
@@ -28,6 +28,14 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.InterestHolderId, src => src.InterestHolderId)
.Map(dest => dest.LegacyPayee, src => src.LegacyPayee)
.Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.CompReqAcqPayeeId, src => src.CompReqAcqPayeeId)
+ .Map(dest => dest.CompensationRequisitionId, src => src.CompensationRequisitionId)
+ .Map(dest => dest.AcquisitionFileTeamId, src => src.AcquisitionFileTeamId)
+ .Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId)
+ .Map(dest => dest.InterestHolderId, src => src.InterestHolderId)
+ .Map(dest => dest.LegacyPayee, src => src.LegacyPayee);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqLeasePayeeMap.cs b/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqLeasePayeeMap.cs
index b05ef2ff0b..03f39e7dd0 100644
--- a/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqLeasePayeeMap.cs
+++ b/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompReqLeasePayeeMap.cs
@@ -15,11 +15,16 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.LeaseStakeholder, src => src.LeaseStakeholder)
.Inherits();
- config.NewConfig()
+ config.NewConfig()
.Map(dest => dest.CompReqLeasePayeeId, src => src.CompReqLeasePayeeId)
.Map(dest => dest.CompensationRequisitionId, src => src.CompensationRequisitionId)
.Map(dest => dest.LeaseStakeholderId, src => src.LeaseStakeholderId)
.Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.CompReqLeasePayeeId, src => src.CompReqLeasePayeeId)
+ .Map(dest => dest.CompensationRequisitionId, src => src.CompensationRequisitionId)
+ .Map(dest => dest.LeaseStakeholderId, src => src.LeaseStakeholderId);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs b/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs
index 8358329029..bd578a6474 100644
--- a/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs
+++ b/source/backend/apimodels/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs
@@ -65,6 +65,26 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.PimsPropAcqFlCompReqs, src => src.CompReqAcquisitionProperties)
.Map(dest => dest.PimsPropLeaseCompReqs, src => src.CompReqLeaseProperties)
.Inherits();
+
+ config
+ .NewConfig()
+ .Map(dest => dest.Id, src => src.CompensationRequisitionId)
+ .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
+ .Map(dest => dest.LeaseId, src => src.LeaseId)
+ .Map(dest => dest.IsDraft, src => src.IsDraft)
+ .Map(dest => dest.FiscalYear, src => src.FiscalYear)
+ .Map(dest => dest.YearlyFinancialId, src => src.YearlyFinancialId)
+ .Map(dest => dest.ChartOfAccountsId, src => src.ChartOfAccountsId)
+ .Map(dest => dest.ResponsibilityId, src => src.ResponsibilityId)
+ .Map(dest => dest.FinalizedDate, src => src.FinalizedDate)
+ .Map(dest => dest.AgreementDate, src => src.AgreementDt)
+ .Map(dest => dest.GenerationDate, src => src.GenerationDt)
+ .Map(dest => dest.IsPaymentInTrust, src => src.IsPaymentInTrust)
+ .Map(dest => dest.GstNumber, src => src.GstNumber)
+ .Map(dest => dest.FinalizedDate, src => src.FinalizedDate)
+ .Map(dest => dest.SpecialInstruction, src => src.SpecialInstruction)
+ .Map(dest => dest.DetailedRemarks, src => src.DetailedRemarks)
+ .Map(dest => dest.AlternateProjectId, src => src.AlternateProjectId);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/Deposit/SecurityDepositReturnMap.cs b/source/backend/apimodels/Models/Concepts/Deposit/SecurityDepositReturnMap.cs
index 9f4397067a..f4a66a0900 100644
--- a/source/backend/apimodels/Models/Concepts/Deposit/SecurityDepositReturnMap.cs
+++ b/source/backend/apimodels/Models/Concepts/Deposit/SecurityDepositReturnMap.cs
@@ -1,6 +1,6 @@
+using System;
using Mapster;
using Pims.Api.Models.Base;
-using System;
using Entity = Pims.Dal.Entities;
namespace Pims.Api.Models.Concepts.Deposit
diff --git a/source/backend/apimodels/Models/Concepts/DispositionFile/DispositionFilePropertyMap.cs b/source/backend/apimodels/Models/Concepts/DispositionFile/DispositionFilePropertyMap.cs
index bbe85d8e05..c79c7b7ab1 100644
--- a/source/backend/apimodels/Models/Concepts/DispositionFile/DispositionFilePropertyMap.cs
+++ b/source/backend/apimodels/Models/Concepts/DispositionFile/DispositionFilePropertyMap.cs
@@ -12,6 +12,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.Id, src => src.DispositionFilePropertyId)
.Map(dest => dest.Location, src => src.Location)
.Map(dest => dest.PropertyName, src => src.PropertyName)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
.Map(dest => dest.Property, src => src.Property)
.Map(dest => dest.PropertyId, src => src.PropertyId)
.Map(dest => dest.File, src => src.DispositionFile)
@@ -22,6 +23,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.DispositionFilePropertyId, src => src.Id)
.Map(dest => dest.Location, src => src.Location)
.Map(dest => dest.PropertyName, src => src.PropertyName)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
.Map(dest => dest.Property, src => src.Property)
.Map(dest => dest.PropertyId, src => src.Property.Id)
.Map(dest => dest.DispositionFileId, src => src.FileId)
diff --git a/source/backend/apimodels/Models/Concepts/Document/DocumentRelationshipMap.cs b/source/backend/apimodels/Models/Concepts/Document/DocumentRelationshipMap.cs
index 7888bacc11..26c94112ea 100644
--- a/source/backend/apimodels/Models/Concepts/Document/DocumentRelationshipMap.cs
+++ b/source/backend/apimodels/Models/Concepts/Document/DocumentRelationshipMap.cs
@@ -1,5 +1,4 @@
using Mapster;
-
using Pims.Api.Models.Base;
using Pims.Api.Models.CodeTypes;
using Entity = Pims.Dal.Entities;
@@ -80,7 +79,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.Id, src => src.Internal_Id)
.Map(dest => dest.ParentId, src => src.FileId)
.Map(dest => dest.Document, src => src.Document)
- .Map(dest => dest.RelationshipType, src => DocumentRelationType.ManagementFiles)
+ .Map(dest => dest.RelationshipType, src => DocumentRelationType.ManagementActivities)
.Inherits();
config.NewConfig()
@@ -101,6 +100,32 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.FileId, src => src.ParentId)
.Map(dest => dest.DocumentId, src => src.Document.Id)
.Map(dest => dest.Document, src => src.Document);
+
+ config.NewConfig()
+ .Map(dest => dest.Id, src => src.Internal_Id)
+ .Map(dest => dest.ParentId, src => src.FileId)
+ .Map(dest => dest.Document, src => src.Document)
+ .Map(dest => dest.RelationshipType, src => DocumentRelationType.ManagementFiles)
+ .Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.Internal_Id, src => src.Id)
+ .Map(dest => dest.FileId, src => src.ParentId)
+ .Map(dest => dest.DocumentId, src => src.Document.Id)
+ .Map(dest => dest.Document, src => src.Document);
+
+ config.NewConfig()
+ .Map(dest => dest.Id, src => src.Internal_Id)
+ .Map(dest => dest.ParentId, src => src.FileId)
+ .Map(dest => dest.Document, src => src.Document)
+ .Map(dest => dest.RelationshipType, src => DocumentRelationType.Properties)
+ .Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.Internal_Id, src => src.Id)
+ .Map(dest => dest.FileId, src => src.ParentId)
+ .Map(dest => dest.DocumentId, src => src.Document.Id)
+ .Map(dest => dest.Document, src => src.Document);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs b/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs
index 216db81e4a..dc53619d83 100644
--- a/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs
+++ b/source/backend/apimodels/Models/Concepts/DocumentQueue/DocumentQueueModel.cs
@@ -70,6 +70,6 @@ public class DocumentQueueModel : BaseAuditModel
/// get/set - The queue status type.
///
public CodeTypeModel DocumentQueueStatusTypeCode { get; set; }
- #endregion
+ #endregion
}
}
diff --git a/source/backend/apimodels/Models/Concepts/FinancialCode/FinancialCodeMap.cs b/source/backend/apimodels/Models/Concepts/FinancialCode/FinancialCodeMap.cs
index 1ba600c8ab..746c159500 100644
--- a/source/backend/apimodels/Models/Concepts/FinancialCode/FinancialCodeMap.cs
+++ b/source/backend/apimodels/Models/Concepts/FinancialCode/FinancialCodeMap.cs
@@ -16,6 +16,13 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.ExpiryDate, src => src.ExpiryDate)
.Inherits();
+ config.NewConfig()
+ .Map(dest => dest.Code, src => src.Code)
+ .Map(dest => dest.Description, src => src.Description)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
+ .Map(dest => dest.EffectiveDate, src => src.EffectiveDate)
+ .Map(dest => dest.ExpiryDate, src => src.ExpiryDate);
+
config.NewConfig()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.Type, src => FinancialCodeTypes.BusinessFunction)
diff --git a/source/backend/apimodels/Models/Concepts/InterestHolder/InterestHolderMap.cs b/source/backend/apimodels/Models/Concepts/InterestHolder/InterestHolderMap.cs
index e78c178f09..47f0f02b54 100644
--- a/source/backend/apimodels/Models/Concepts/InterestHolder/InterestHolderMap.cs
+++ b/source/backend/apimodels/Models/Concepts/InterestHolder/InterestHolderMap.cs
@@ -8,7 +8,8 @@ public class InterestHolderMap : IRegister
{
public void Register(TypeAdapterConfig config)
{
- config.NewConfig()
+ config
+ .NewConfig()
.Map(dest => dest.InterestHolderId, src => src.InterestHolderId)
.Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
.Map(dest => dest.InterestHolderProperties, src => src.PimsInthldrPropInterests)
@@ -23,7 +24,8 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Inherits();
- config.NewConfig()
+ config
+ .NewConfig()
.Map(dest => dest.InterestHolderId, src => src.InterestHolderId)
.Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
.Map(dest => dest.PimsInthldrPropInterests, src => src.InterestHolderProperties)
@@ -36,6 +38,17 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.InterestHolderTypeCode, src => src.InterestHolderType.Id)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Inherits();
+
+ config
+ .NewConfig()
+ .Map(dest => dest.InterestHolderId, src => src.InterestHolderId)
+ .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId)
+ .Map(dest => dest.PersonId, src => src.PersonId)
+ .Map(dest => dest.OrganizationId, src => src.OrganizationId)
+ .Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
+ .Map(dest => dest.Comment, src => src.Comment)
+ .Map(dest => dest.InterestHolderTypeCode, src => src.InterestHolderTypeCode)
+ .Map(dest => dest.IsDisabled, src => src.IsDisabled);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/Lease/LeaseFileTeamMap.cs b/source/backend/apimodels/Models/Concepts/Lease/LeaseFileTeamMap.cs
index 3d47891696..f22ff9e5c3 100644
--- a/source/backend/apimodels/Models/Concepts/Lease/LeaseFileTeamMap.cs
+++ b/source/backend/apimodels/Models/Concepts/Lease/LeaseFileTeamMap.cs
@@ -29,6 +29,14 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
.Map(dest => dest.LlTeamProfileTypeCode, src => src.TeamProfileTypeCode)
.Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.LeaseLicenseTeamId, src => src.LeaseLicenseTeamId)
+ .Map(dest => dest.LeaseId, src => src.LeaseId)
+ .Map(dest => dest.PersonId, src => src.PersonId)
+ .Map(dest => dest.OrganizationId, src => src.OrganizationId)
+ .Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
+ .Map(dest => dest.LlTeamProfileTypeCode, src => src.LlTeamProfileTypeCode);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/Lease/LeaseMap.cs b/source/backend/apimodels/Models/Concepts/Lease/LeaseMap.cs
index ace9f9498b..6c5248646d 100644
--- a/source/backend/apimodels/Models/Concepts/Lease/LeaseMap.cs
+++ b/source/backend/apimodels/Models/Concepts/Lease/LeaseMap.cs
@@ -52,6 +52,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.HasPhysicalLicense, src => src.HasPhysicialLicense)
.Map(dest => dest.CancellationReason, src => src.CancellationReason)
.Map(dest => dest.TerminationReason, src => src.TerminationReason)
+ .Map(dest => dest.ProjectId, src => src.ProjectId)
.Map(dest => dest.Project, src => src.Project)
.Map(dest => dest.ProductId, src => src.ProductId)
.Map(dest => dest.Product, src => src.Product)
@@ -112,6 +113,44 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.PimsLeaseRenewals, src => src.Renewals)
.Map(dest => dest.PimsLeaseLicenseTeams, src => src.LeaseTeam)
.IgnoreNullValues(true);
+
+ config.NewConfig()
+ .Map(dest => dest.LeaseId, src => src.LeaseId)
+ .Map(dest => dest.LeaseAmount, src => src.LeaseAmount)
+ .Map(dest => dest.LFileNo, src => src.LFileNo)
+ .Map(dest => dest.PsFileNo, src => src.PsFileNo)
+ .Map(dest => dest.TfaFileNumber, src => src.TfaFileNumber)
+ .Map(dest => dest.MotiContact, src => src.MotiContact)
+ .Map(dest => dest.OtherLeaseProgramType, src => src.OtherLeaseProgramType)
+ .Map(dest => dest.OtherLeaseLicenseType, src => src.OtherLeaseLicenseType)
+ .Map(dest => dest.OrigExpiryDate, src => src.OrigExpiryDate)
+ .Map(dest => dest.OrigStartDate, src => src.OrigStartDate)
+ .Map(dest => dest.TerminationDate, src => src.TerminationDate)
+ .Map(dest => dest.RegionCode, src => src.RegionCode)
+ .Map(dest => dest.LeaseProgramTypeCode, src => src.LeaseProgramTypeCode)
+ .Map(dest => dest.LeasePayRvblTypeCode, src => src.LeasePayRvblTypeCode)
+ .Map(dest => dest.LeaseLicenseTypeCode, src => src.LeaseLicenseTypeCode)
+ .Map(dest => dest.LeaseInitiatorTypeCode, src => src.LeaseInitiatorTypeCode)
+ .Map(dest => dest.LeaseResponsibilityTypeCode, src => src.LeaseResponsibilityTypeCode)
+ .Map(dest => dest.LeaseStatusTypeCode, src => src.LeaseStatusTypeCode)
+ .Map(dest => dest.ResponsibilityEffectiveDate, src => src.ResponsibilityEffectiveDate)
+ .Map(dest => dest.DocumentationReference, src => src.DocumentationReference)
+ .Map(dest => dest.LeaseNotes, src => src.LeaseNotes)
+ .Map(dest => dest.LeaseDescription, src => src.LeaseDescription)
+ .Map(dest => dest.IsExpired, src => src.IsExpired)
+ .Map(dest => dest.HasPhysicalFile, src => src.HasPhysicalFile)
+ .Map(dest => dest.HasPhysicialLicense, src => src.HasPhysicialLicense)
+ .Map(dest => dest.HasDigitalFile, src => src.HasDigitalFile)
+ .Map(dest => dest.HasDigitalLicense, src => src.HasDigitalLicense)
+ .Map(dest => dest.CancellationReason, src => src.CancellationReason)
+ .Map(dest => dest.TerminationReason, src => src.TerminationReason)
+ .Map(dest => dest.PrimaryArbitrationCity, src => src.PrimaryArbitrationCity)
+ .Map(dest => dest.ProjectId, src => src.ProjectId)
+ .Map(dest => dest.ProductId, src => src.ProductId)
+ .Map(dest => dest.TotalAllowableCompensation, src => src.TotalAllowableCompensation)
+ .Map(dest => dest.IsPublicBenefit, src => src.IsPublicBenefit)
+ .Map(dest => dest.IsFinancialGain, src => src.IsFinancialGain)
+ .Map(dest => dest.FeeDeterminationNote, src => src.FeeDeterminationNote);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/Lease/LeaseModel.cs b/source/backend/apimodels/Models/Concepts/Lease/LeaseModel.cs
index cbcd6c8cea..c204a2d8ea 100644
--- a/source/backend/apimodels/Models/Concepts/Lease/LeaseModel.cs
+++ b/source/backend/apimodels/Models/Concepts/Lease/LeaseModel.cs
@@ -4,7 +4,6 @@
using Pims.Api.Models.Concepts.File;
using Pims.Api.Models.Concepts.Product;
using Pims.Api.Models.Concepts.Project;
-using Pims.Dal.Entities;
namespace Pims.Api.Models.Concepts.Lease
{
@@ -169,6 +168,8 @@ public class LeaseModel : FileWithChecklistModel
public bool IsExpired { get; set; }
+ public long? ProjectId { get; set; }
+
///
/// get/set - The project associated with this lease.
///
diff --git a/source/backend/apimodels/Models/Concepts/Lease/LeasePeriodModel.cs b/source/backend/apimodels/Models/Concepts/Lease/LeasePeriodModel.cs
index fde5e847e2..8e642343be 100644
--- a/source/backend/apimodels/Models/Concepts/Lease/LeasePeriodModel.cs
+++ b/source/backend/apimodels/Models/Concepts/Lease/LeasePeriodModel.cs
@@ -97,7 +97,7 @@ public class LeasePeriodModel : BaseAuditModel
public bool IsVariable { get; set; }
///
- /// get/set - Additional rent payment amount
+ /// get/set - Additional rent payment amount.
///
public decimal? AdditionalRentPaymentAmount { get; set; }
@@ -112,7 +112,7 @@ public class LeasePeriodModel : BaseAuditModel
public CodeTypeModel AdditionalRentFreqTypeCode { get; set; }
///
- /// get/set - Variable rent payment amount
+ /// get/set - Variable rent payment amount.
///
public decimal? VariableRentPaymentAmount { get; set; }
diff --git a/source/backend/apimodels/Models/Concepts/Lease/LeaseRenewalModel.cs b/source/backend/apimodels/Models/Concepts/Lease/LeaseRenewalModel.cs
index e82f3b7c2e..f8bb01fece 100644
--- a/source/backend/apimodels/Models/Concepts/Lease/LeaseRenewalModel.cs
+++ b/source/backend/apimodels/Models/Concepts/Lease/LeaseRenewalModel.cs
@@ -1,4 +1,3 @@
-
using System;
using Pims.Api.Models.Base;
diff --git a/source/backend/apimodels/Models/Concepts/Lease/LeaseStakeholderMap.cs b/source/backend/apimodels/Models/Concepts/Lease/LeaseStakeholderMap.cs
index 089220488e..85c0699580 100644
--- a/source/backend/apimodels/Models/Concepts/Lease/LeaseStakeholderMap.cs
+++ b/source/backend/apimodels/Models/Concepts/Lease/LeaseStakeholderMap.cs
@@ -32,6 +32,16 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.LeaseStakeholderTypeCode, src => src.StakeholderTypeCode.Id)
.Map(dest => dest.LessorTypeCode, src => src.LessorType.Id)
.Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.LeaseStakeholderId, src => src.LeaseStakeholderId)
+ .Map(dest => dest.LeaseId, src => src.LeaseId)
+ .Map(dest => dest.OrganizationId, src => src.OrganizationId)
+ .Map(dest => dest.PersonId, src => src.PersonId)
+ .Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
+ .Map(dest => dest.Note, src => src.Note)
+ .Map(dest => dest.LeaseStakeholderTypeCode, src => src.LeaseStakeholderTypeCode)
+ .Map(dest => dest.LessorTypeCode, src => src.LessorTypeCode);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/Lease/PropertyLeaseMap.cs b/source/backend/apimodels/Models/Concepts/Lease/PropertyLeaseMap.cs
index 0232f2acac..a88942d39e 100644
--- a/source/backend/apimodels/Models/Concepts/Lease/PropertyLeaseMap.cs
+++ b/source/backend/apimodels/Models/Concepts/Lease/PropertyLeaseMap.cs
@@ -18,6 +18,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.LeaseArea, src => src.LeaseArea)
.Map(dest => dest.PropertyName, src => src.Name)
.Map(dest => dest.Location, src => src.Location)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
.Map(dest => dest.Id, src => src.Internal_Id)
.Inherits();
@@ -29,8 +30,18 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.LeaseArea, src => src.LeaseArea)
.Map(dest => dest.Name, src => src.PropertyName)
.Map(dest => dest.Location, src => src.Location)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
.Map(dest => dest.Internal_Id, src => src.Id)
.Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.PropertyLeaseId, src => src.PropertyLeaseId)
+ .Map(dest => dest.PropertyId, src => src.PropertyId)
+ .Map(dest => dest.LeaseId, src => src.LeaseId)
+ .Map(dest => dest.AreaUnitTypeCode, src => src.AreaUnitTypeCode)
+ .Map(dest => dest.LeaseArea, src => src.LeaseArea)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
+ .Map(dest => dest.Name, src => src.Name);
}
}
}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementActivity/ManagementActivitySubTypeMap.cs b/source/backend/apimodels/Models/Concepts/ManagementActivity/ManagementActivitySubTypeMap.cs
new file mode 100644
index 0000000000..4fb70aca7b
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementActivity/ManagementActivitySubTypeMap.cs
@@ -0,0 +1,25 @@
+using Mapster;
+using Pims.Api.Models.Base;
+using Pims.Api.Models.Concepts.ManagementActivity;
+using Entity = Pims.Dal.Entities;
+
+namespace Pims.Api.Models.Models.Concepts.ManagementActivity
+{
+ public class ManagementActivitySubTypeMap : IRegister
+ {
+ public void Register(TypeAdapterConfig config)
+ {
+ config.NewConfig()
+ .Map(dest => dest.Id, src => src.PropActvtyMgmtActvtyTypId)
+ .Map(dest => dest.ManagementActivityId, src => src.PimsPropertyActivityId)
+ .Map(dest => dest.ManagementActivitySubtypeCode, src => src.PropMgmtActivitySubtypeCodeNavigation)
+ .Inherits();
+
+ config.NewConfig()
+ .Map(dest => dest.PropActvtyMgmtActvtyTypId, src => src.Id)
+ .Map(dest => dest.PimsPropertyActivityId, src => src.ManagementActivityId)
+ .Map(dest => dest.PropMgmtActivitySubtypeCode, src => src.ManagementActivitySubtypeCode.Id)
+ .Inherits();
+ }
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementActivity/ManagementActivitySubTypeModel.cs b/source/backend/apimodels/Models/Concepts/ManagementActivity/ManagementActivitySubTypeModel.cs
new file mode 100644
index 0000000000..7defe08f26
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementActivity/ManagementActivitySubTypeModel.cs
@@ -0,0 +1,22 @@
+using Pims.Api.Models.Base;
+
+namespace Pims.Api.Models.Concepts.ManagementActivity
+{
+ public class ManagementActivitySubTypeModel : BaseAuditModel
+ {
+ ///
+ /// get/set - Management Activity Subtype Id.
+ ///
+ public long Id { get; set; }
+
+ ///
+ /// get/set - Management Activity Parent Id.
+ ///
+ public long ManagementActivityId { get; set; }
+
+ ///
+ /// get/set - Sub-Type Code Definition.
+ ///
+ public CodeTypeModel ManagementActivitySubtypeCode { get; set; }
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileMap.cs b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileMap.cs
new file mode 100644
index 0000000000..583641e140
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileMap.cs
@@ -0,0 +1,44 @@
+using System.Collections.Immutable;
+using Mapster;
+using Entity = Pims.Dal.Entities;
+
+namespace Pims.Api.Models.Concepts.ManagementFile
+{
+ public class ManagementFileMap : IRegister
+ {
+ public void Register(TypeAdapterConfig config)
+ {
+ config.NewConfig()
+ .PreserveReference(true)
+ .Map(dest => dest.Id, src => src.ManagementFileId)
+ .Map(dest => dest.FileName, src => src.FileName)
+ .Map(dest => dest.AdditionalDetails, src => src.AdditionalDetails)
+ .Map(dest => dest.FilePurpose, src => src.FilePurpose)
+ .Map(dest => dest.LegacyFileNum, src => src.LegacyFileNum)
+ .Map(dest => dest.ProjectId, src => src.ProjectId)
+ .Map(dest => dest.Project, src => src.Project)
+ .Map(dest => dest.ProductId, src => src.ProductId)
+ .Map(dest => dest.Product, src => src.Product)
+ .Map(dest => dest.FileStatusTypeCode, src => src.ManagementFileStatusTypeCodeNavigation)
+ .Map(dest => dest.FundingTypeCode, src => src.AcquisitionFundingTypeCodeNavigation)
+ .Map(dest => dest.PurposeTypeCode, src => src.ManagementFilePurposeTypeCodeNavigation)
+ .Map(dest => dest.ManagementTeam, src => src.PimsManagementFileTeams)
+ .Map(dest => dest.FileProperties, src => src.PimsManagementFileProperties);
+
+ config.NewConfig()
+ .PreserveReference(true)
+ .Map(dest => dest.ManagementFileId, src => src.Id)
+ .Map(dest => dest.FileName, src => src.FileName)
+ .Map(dest => dest.AdditionalDetails, src => src.AdditionalDetails)
+ .Map(dest => dest.FilePurpose, src => src.FilePurpose)
+ .Map(dest => dest.LegacyFileNum, src => src.LegacyFileNum)
+ .Map(dest => dest.ProjectId, src => src.ProjectId)
+ .Map(dest => dest.ProductId, src => src.ProductId)
+ .Map(dest => dest.ManagementFileStatusTypeCode, src => src.FileStatusTypeCode.Id)
+ .Map(dest => dest.AcquisitionFundingTypeCode, src => src.FundingTypeCode != null ? src.FundingTypeCode.Id : null)
+ .Map(dest => dest.ManagementFilePurposeTypeCode, src => src.PurposeTypeCode != null ? src.PurposeTypeCode.Id : null)
+ .Map(dest => dest.PimsManagementFileTeams, src => src.ManagementTeam)
+ .Map(dest => dest.PimsManagementFileProperties, src => src.FileProperties.ToImmutableList());
+ }
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileModel.cs b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileModel.cs
new file mode 100644
index 0000000000..6df341d7c2
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileModel.cs
@@ -0,0 +1,70 @@
+using System.Collections.Generic;
+using Pims.Api.Models.Base;
+using Pims.Api.Models.Concepts.File;
+using Pims.Api.Models.Concepts.Product;
+using Pims.Api.Models.Concepts.Project;
+
+namespace Pims.Api.Models.Concepts.ManagementFile
+{
+ public class ManagementFileModel : FileModel
+ {
+ #region Properties
+
+ ///
+ /// get/set - The file's purpose.
+ ///
+ public string FilePurpose { get; set; }
+
+ ///
+ /// get/set - The file's details.
+ ///
+ public string AdditionalDetails { get; set; }
+
+ ///
+ /// get/set - The file's legacy file number.
+ ///
+ public string LegacyFileNum { get; set; }
+
+ ///
+ /// get/set - The project's id.
+ ///
+ public long? ProjectId { get; set; }
+
+ ///
+ /// get/set - The management project.
+ ///
+ public ProjectModel Project { get; set; }
+
+ ///
+ /// get/set - The product's id.
+ ///
+ public long? ProductId { get; set; }
+
+ ///
+ /// get/set - The product.
+ ///
+ public ProductModel Product { get; set; }
+
+ ///
+ /// get/set - The funding management file falls under.
+ ///
+ public CodeTypeModel FundingTypeCode { get; set; }
+
+ ///
+ /// get/set - The program management file falls under.
+ ///
+ public CodeTypeModel PurposeTypeCode { get; set; }
+
+ ///
+ /// get/set - A list of management file properties.
+ ///
+ public new IList FileProperties { get; set; }
+
+ ///
+ /// get/set - A list of management file team relationships.
+ ///
+ public IList ManagementTeam { get; set; }
+
+ #endregion
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFilePropertyMap.cs b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFilePropertyMap.cs
new file mode 100644
index 0000000000..5af6ce2cbb
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFilePropertyMap.cs
@@ -0,0 +1,34 @@
+using Mapster;
+using Pims.Api.Models.Base;
+using Entity = Pims.Dal.Entities;
+
+namespace Pims.Api.Models.Concepts.ManagementFile
+{
+ public class ManagementFilePropertyMap : IRegister
+ {
+ public void Register(TypeAdapterConfig config)
+ {
+ // Map from Entity to Model
+ config.NewConfig()
+ .PreserveReference(true)
+ .Map(dest => dest.Id, src => src.ManagementFilePropertyId)
+ .Map(dest => dest.FileId, src => src.ManagementFileId)
+ .Map(dest => dest.PropertyName, src => src.PropertyName)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
+ .Map(dest => dest.PropertyId, src => src.PropertyId)
+ .Map(dest => dest.Property, src => src.Property)
+ .Inherits();
+
+ // Map from Model to Entity
+ config.NewConfig()
+ .PreserveReference(true)
+ .Map(dest => dest.ManagementFilePropertyId, src => src.Id)
+ .Map(dest => dest.ManagementFileId, src => src.FileId)
+ .Map(dest => dest.PropertyName, src => src.PropertyName)
+ .Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
+ .Map(dest => dest.PropertyId, src => src.PropertyId)
+ .Map(dest => dest.Property, src => src.Property)
+ .Inherits();
+ }
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFilePropertyModel.cs b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFilePropertyModel.cs
new file mode 100644
index 0000000000..319c7cc951
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFilePropertyModel.cs
@@ -0,0 +1,15 @@
+using Pims.Api.Models.Concepts.File;
+
+namespace Pims.Api.Models.Concepts.ManagementFile
+{
+ public class ManagementFilePropertyModel : FilePropertyModel
+ {
+ #region Properties
+
+ ///
+ /// get/set - The relationship's disposition file.
+ ///
+ public new ManagementFileModel File { get; set; }
+ #endregion
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileTeamMap.cs b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileTeamMap.cs
new file mode 100644
index 0000000000..d391d8ef7e
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileTeamMap.cs
@@ -0,0 +1,38 @@
+using Mapster;
+using Pims.Api.Models.Base;
+using Entity = Pims.Dal.Entities;
+
+namespace Pims.Api.Models.Concepts.ManagementFile
+{
+ public class ManagementFileTeamMap : IRegister
+ {
+ public void Register(TypeAdapterConfig config)
+ {
+ // Map from Entity to Model
+ config.NewConfig()
+ .PreserveReference(true)
+ .Map(dest => dest.Id, src => src.PimsManagementFileTeamId)
+ .Map(dest => dest.ManagementFileId, src => src.ManagementFileId)
+ .Map(dest => dest.PersonId, src => src.PersonId)
+ .Map(dest => dest.Person, src => src.Person)
+ .Map(dest => dest.OrganizationId, src => src.OrganizationId)
+ .Map(dest => dest.Organization, src => src.Organization)
+ .Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
+ .Map(dest => dest.PrimaryContact, src => src.PrimaryContact)
+ .Map(dest => dest.TeamProfileTypeCode, src => src.ManagementFileProfileTypeCode)
+ .Map(dest => dest.TeamProfileType, src => src.ManagementFileProfileTypeCodeNavigation)
+ .Inherits();
+
+ // Map from Model to Entity
+ config.NewConfig()
+ .PreserveReference(true)
+ .Map(dest => dest.PimsManagementFileTeamId, src => src.Id)
+ .Map(dest => dest.ManagementFileId, src => src.ManagementFileId)
+ .Map(dest => dest.PersonId, src => src.PersonId)
+ .Map(dest => dest.OrganizationId, src => src.OrganizationId)
+ .Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
+ .Map(dest => dest.ManagementFileProfileTypeCode, src => src.TeamProfileTypeCode)
+ .Inherits();
+ }
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileTeamModel.cs b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileTeamModel.cs
new file mode 100644
index 0000000000..48f6e57d94
--- /dev/null
+++ b/source/backend/apimodels/Models/Concepts/ManagementFile/ManagementFileTeamModel.cs
@@ -0,0 +1,63 @@
+using Pims.Api.Models.Base;
+using Pims.Api.Models.Concepts.Organization;
+using Pims.Api.Models.Concepts.Person;
+
+namespace Pims.Api.Models.Concepts.ManagementFile
+{
+ public class ManagementFileTeamModel : BaseConcurrentModel
+ {
+ #region Properties
+
+ ///
+ /// get/set - The unique identifier for the management file team.
+ ///
+ public long Id { get; set; }
+
+ ///
+ /// get/set - The management file ID this team is associated with.
+ ///
+ public long ManagementFileId { get; set; }
+
+ ///
+ /// get/set - The person ID associated with the team.
+ ///
+ public long? PersonId { get; set; }
+
+ ///
+ /// get/set - The person associated with a management file as part of the management team.
+ ///
+ public PersonModel Person { get; set; }
+
+ ///
+ /// get/set - The organization ID associated with the team.
+ ///
+ public long? OrganizationId { get; set; }
+
+ ///
+ /// get/set - The organization associated with a management file as part of the management team.
+ ///
+ public OrganizationModel Organization { get; set; }
+
+ ///
+ /// get/set - The primary contact ID for the organization.
+ ///
+ public long? PrimaryContactId { get; set; }
+
+ ///
+ /// get/set - The primary contact associated with a management file as part of the management team.
+ ///
+ public PersonModel PrimaryContact { get; set; }
+
+ ///
+ /// get/set - The Team's profile type code.
+ ///
+ public string TeamProfileTypeCode { get; set; }
+
+ ///
+ /// get/set - The Team's profile type code.
+ ///
+ public CodeTypeModel TeamProfileType { get; set; }
+
+ #endregion
+ }
+}
diff --git a/source/backend/apimodels/Models/Concepts/Note/EntityNoteModelMap.cs b/source/backend/apimodels/Models/Concepts/Note/EntityNoteModelMap.cs
index 2f0f3d609e..6590c33bc1 100644
--- a/source/backend/apimodels/Models/Concepts/Note/EntityNoteModelMap.cs
+++ b/source/backend/apimodels/Models/Concepts/Note/EntityNoteModelMap.cs
@@ -50,12 +50,28 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.LeaseId, src => src.Parent.Id)
.Inherits();
+ // PimsManagementNote -> EntityNoteModel
+ config.NewConfig()
+ .Map(dest => dest.Id, src => src.ManagementFileNoteId)
+ .Map(dest => dest.Note, src => src.Note)
+ .Map(dest => dest.Parent, src => src)
+ .Inherits();
+
+ // PimsManagementNote <- EntityNoteModel
+ config.NewConfig()
+ .Map(dest => dest.ManagementFileNoteId, src => src.Id)
+ .Map(dest => dest.Note, src => src.Note)
+ .Map(dest => dest.ManagementFileId, src => src.Parent.Id)
+ .Inherits();
+
+ // PimsProjectNote -> EntityNoteModel
config.NewConfig()
.Map(dest => dest.Id, src => src.ProjectNoteId)
.Map(dest => dest.Note, src => src.Note)
.Map(dest => dest.Parent, src => src)
.Inherits();
+ // PimsProjectNote <- EntityNoteModel
config.NewConfig()
.Map(dest => dest.ProjectNoteId, src => src.Id)
.Map(dest => dest.Note, src => src.Note)
@@ -76,6 +92,20 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.ResearchFileId, src => src.Parent.Id)
.Inherits();
+ // PimsPropertyNote -> EntityNoteModel
+ config.NewConfig()
+ .Map(dest => dest.Id, src => src.PropertyNoteId)
+ .Map(dest => dest.Note, src => src.Note)
+ .Map(dest => dest.Parent, src => src)
+ .Inherits();
+
+ // PimsPropertyNote <- EntityNoteModel
+ config.NewConfig()
+ .Map(dest => dest.PropertyNoteId, src => src.Id)
+ .Map(dest => dest.Note, src => src.Note)
+ .Map(dest => dest.PropertyId, src => src.Parent.Id)
+ .Inherits