Skip to content

Commit

Permalink
Merge pull request #3283 from bcgov/release/is55_uat
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Jun 22, 2023
2 parents 1cf63d5 + 570ea27 commit 0cb3947
Show file tree
Hide file tree
Showing 547 changed files with 93,141 additions and 11,102 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:

- name: Setup git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Create release
id: create_release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:

- name: Setup git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Check release version
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:

- name: Setup git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Bump version number
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Areas.CompensationRequisition.Controllers;
using Pims.Api.Models;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Extensions;
using Pims.Core.Json;
using Pims.Dal.Exceptions;
using Pims.Dal.Entities;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;

Expand Down Expand Up @@ -117,6 +117,7 @@ public IActionResult AddAcquisitionFile([FromBody] AcquisitionFileModel model, [
[HasPermission(Permissions.AcquisitionFileEdit)]
[Produces("application/json")]
[ProducesResponseType(typeof(AcquisitionFileModel), 200)]
[ProducesResponseType(typeof(ErrorResponseModel), 409)]
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
public IActionResult UpdateAcquisitionFile(long id, [FromBody] AcquisitionFileModel model, [FromQuery] string[] userOverrideCodes)
{
Expand Down Expand Up @@ -182,6 +183,38 @@ public IActionResult GetAcquisitionFileOwners([FromRoute] long id)
return new JsonResult(_mapper.Map<IEnumerable<AcquisitionFileOwnerModel>>(owners));
}

/// <summary>
/// Get the acquisition file Owner representatives.
/// </summary>
/// <returns></returns>
[HttpGet("{id:long}/owner-representatives")]
[HasPermission(Permissions.AcquisitionFileView)]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<AcquisitionFileOwnerRepresentativeModel>), 200)]
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
public IActionResult GetAcquisitionFileOwnerRepresentatives([FromRoute] long id)
{
var owners = _acquisitionService.GetOwnerRepresentatives(id);

return new JsonResult(_mapper.Map<IEnumerable<AcquisitionFileOwnerRepresentativeModel>>(owners));
}

/// <summary>
/// Get the acquisition file Owner solicitors.
/// </summary>
/// <returns></returns>
[HttpGet("{id:long}/owner-solicitors")]
[HasPermission(Permissions.AcquisitionFileView)]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<AcquisitionFileOwnerSolicitorModel>), 200)]
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
public IActionResult GetAcquisitionFileOwnerSolicitors([FromRoute] long id)
{
var owners = _acquisitionService.GetOwnerSolicitors(id);

return new JsonResult(_mapper.Map<IEnumerable<AcquisitionFileOwnerSolicitorModel>>(owners));
}

/// <summary>
/// Get all the compensations corresponding to the passed file id.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System.Collections.Generic;
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pims.Api.Models;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
using Pims.Core.Json;
using Pims.Dal.Security;
using Swashbuckle.AspNetCore.Annotations;

namespace Pims.Api.Areas.Acquisition.Controllers
{
/// <summary>
/// InterestHolderController class, provides endpoints for interacting with acquisition file InterestHolders.
/// </summary>
[Authorize]
[ApiController]
[ApiVersion("1.0")]
[Area("acquisitionfiles")]
[Route("v{version:apiVersion}/[area]")]
[Route("[area]")]
public class InterestHolderController : ControllerBase
{
#region Variables
private readonly IAcquisitionFileService _acquisitionService;
private readonly IMapper _mapper;
#endregion

#region Constructors

/// <summary>
/// Creates a new instance of a InterestHolderController class, initializes it with the specified arguments.
/// </summary>
/// <param name="acquisitionService"></param>
/// <param name="mapper"></param>
///
public InterestHolderController(IAcquisitionFileService acquisitionService, IMapper mapper)
{
_acquisitionService = acquisitionService;
_mapper = mapper;
}
#endregion

#region Endpoints

/// <summary>
/// Get the acquisition file InterestHolders.
/// </summary>
/// <returns>The interest holder items.</returns>
[HttpGet("{id:long}/interestholders")]
[HasPermission(Permissions.AcquisitionFileView)]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<InterestHolderModel>), 200)]
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult GetAcquisitionFileInterestHolders([FromRoute] long id)
{
var interestHolders = _acquisitionService.GetInterestHolders(id);
return new JsonResult(_mapper.Map<List<Api.Models.Concepts.InterestHolderModel>>(interestHolders));
}

/// <summary>
/// Update the acquisition file InterestHolders.
/// </summary>
/// <returns>The updated interest holder items.</returns>
[HttpPut("{id:long}/interestholders")]
[HasPermission(Permissions.AcquisitionFileView)]
[Produces("application/json")]
[ProducesResponseType(typeof(InterestHolderModel), 200)]
[ProducesResponseType(typeof(ErrorResponseModel), 409)]
[SwaggerOperation(Tags = new[] { "acquisitionfile" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult UpdateInterestHolderFile([FromRoute] long id, [FromBody] List<InterestHolderModel> interestHolders)
{
var interestHolderEntities = _mapper.Map<List<Dal.Entities.PimsInterestHolder>>(interestHolders);
var updatedInterestHolders = _acquisitionService.UpdateInterestHolders(id, interestHolderEntities);
return new JsonResult(_mapper.Map<List<Dal.Entities.PimsInterestHolder>>(updatedInterestHolders));
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Pims.Api.Helpers.Exceptions;
using Pims.Api.Models.Concepts;
using Pims.Api.Policies;
using Pims.Api.Services;
Expand Down Expand Up @@ -45,7 +46,7 @@ public CompensationRequisitionController(IMapper mapper, ILogger<CompensationReq
[Produces("application/json")]
[ProducesResponseType(typeof(CompensationRequisitionModel), 200)]
[SwaggerOperation(Tags = new[] { "compensation-requisition" })]
public IActionResult GetCompensationRequisitionById([FromRoute]long id)
public IActionResult GetCompensationRequisitionById([FromRoute] long id)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
Expand All @@ -65,7 +66,7 @@ public IActionResult GetCompensationRequisitionById([FromRoute]long id)
[Produces("application/json")]
[ProducesResponseType(typeof(CompensationRequisitionModel), 200)]
[SwaggerOperation(Tags = new[] { "compensation-requisition" })]
public IActionResult UpdateCompensationRequisition([FromRoute]long id, [FromBody]CompensationRequisitionModel compensationRequisition)
public IActionResult UpdateCompensationRequisition([FromRoute] long id, [FromBody] CompensationRequisitionModel compensationRequisition)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
Expand All @@ -75,8 +76,13 @@ public IActionResult UpdateCompensationRequisition([FromRoute]long id, [FromBody
DateTime.Now);
_logger.LogInformation("Dispatching to service: {Service}", _compensationRequisitionService.GetType());

if (id != compensationRequisition.Id)
{
throw new BadRequestException("Invalid compensationRequisitionId.");
}

var compensationReqEntity = _mapper.Map<Dal.Entities.PimsCompensationRequisition>(compensationRequisition);
var compensation = _compensationRequisitionService.Update(id, compensationReqEntity);
var compensation = _compensationRequisitionService.Update(compensationReqEntity);

return new JsonResult(_mapper.Map<CompensationRequisitionModel>(compensation));
}
Expand All @@ -92,10 +98,35 @@ public IActionResult UpdateCompensationRequisition([FromRoute]long id, [FromBody
[ProducesResponseType(typeof(bool), 200)]
[SwaggerOperation(Tags = new[] { "compensation-requisition" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult DeleteCompensation([FromRoute]long id)
public IActionResult DeleteCompensation([FromRoute] long id)
{
var result = _compensationRequisitionService.DeleteCompensation(id);
return new JsonResult(result);
}

/// <summary>
/// Get the payee for a compensation requisition.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id:long}/payee")]
[HasPermission(Permissions.CompensationRequisitionView)]
[Produces("application/json")]
[ProducesResponseType(typeof(CompensationPayeeModel), 200)]
[SwaggerOperation(Tags = new[] { "compensation-requisition" })]
public IActionResult GetCompensationRequisitionPayee([FromRoute] long id)
{
_logger.LogInformation(
"Request received by Controller: {Controller}, Action: {ControllerAction}, User: {User}, DateTime: {DateTime}",
nameof(CompensationRequisitionController),
nameof(GetCompensationRequisitionPayee),
User.GetUsername(),
DateTime.Now);
_logger.LogInformation("Dispatching to service: {Service}", _compensationRequisitionService.GetType());

var compensationPayee = _compensationRequisitionService.GetPayeeByCompensationId(id);

return new JsonResult(_mapper.Map<CompensationPayeeModel>(compensationPayee));
}
}
}
56 changes: 56 additions & 0 deletions source/backend/api/Areas/FinancialCodes/FinancialCodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,62 @@ public IActionResult GetFinancialCodesByType(FinancialCodeTypes type)
{
return new JsonResult(_financialCodeService.GetFinancialCodesByType(type));
}

/// <summary>
/// Gets financial Activity Type Codes.
/// </summary>
/// <returns>An array with financial activity types codes.</returns>
[HttpGet("financial-activities")]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<FinancialCodeModel>), 200)]
[ProducesResponseType(typeof(Models.ErrorResponseModel), 400)]
[SwaggerOperation(Tags = new[] { "financialcodes" })]
public IActionResult GetFinancialActivityCodes()
{
return new JsonResult(_financialCodeService.GetFinancialCodesByType(FinancialCodeTypes.FinancialActivity));
}

/// <summary>
/// Gets Chart of Acccounts Type Codes.
/// </summary>
/// <returns>An array with chart of accounts types codes.</returns>
[HttpGet("chart-accounts")]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<FinancialCodeModel>), 200)]
[ProducesResponseType(typeof(Models.ErrorResponseModel), 400)]
[SwaggerOperation(Tags = new[] { "financialcodes" })]
public IActionResult GetChartOfAccounts()
{
return new JsonResult(_financialCodeService.GetFinancialCodesByType(FinancialCodeTypes.ChartOfAccounts));
}

/// <summary>
/// Gets Responsibility Type Codes.
/// </summary>
/// <returns>An array with Responsibility types codes.</returns>
[HttpGet("responsibilities")]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<FinancialCodeModel>), 200)]
[ProducesResponseType(typeof(Models.ErrorResponseModel), 400)]
[SwaggerOperation(Tags = new[] { "financialcodes" })]
public IActionResult GetResponsibilities()
{
return new JsonResult(_financialCodeService.GetFinancialCodesByType(FinancialCodeTypes.Responsibility));
}

/// <summary>
/// Gets Yearly Financials Type Codes.
/// </summary>
/// <returns>An array with yearly financials types codes.</returns>
[HttpGet("yearly-financials")]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<FinancialCodeModel>), 200)]
[ProducesResponseType(typeof(Models.ErrorResponseModel), 400)]
[SwaggerOperation(Tags = new[] { "financialcodes" })]
public IActionResult GetYearlyFinancials()
{
return new JsonResult(_financialCodeService.GetFinancialCodesByType(FinancialCodeTypes.YearlyFinancial));
}
#endregion
}
}
4 changes: 4 additions & 0 deletions source/backend/api/Controllers/LookupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ public IActionResult GetAll()
var takeTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllTakeTypes());
var takeStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllTakeStatusTypes());
var takeSiteContamTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllTakeSiteContamTypes());
var landActTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllLandActTypes());
var acqChecklistSectionTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcquisitionChecklistSectionTypes());
var acqChecklistItemStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcquisitionChecklistItemStatusTypes());
var agreementTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAgreementTypes());
var interestHolderTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllInterestHolderTypes());

var codes = new List<object>();
codes.AddRange(areaUnitTypes);
Expand Down Expand Up @@ -197,9 +199,11 @@ public IActionResult GetAll()
codes.AddRange(takeTypes);
codes.AddRange(takeStatusTypes);
codes.AddRange(takeSiteContamTypes);
codes.AddRange(landActTypes);
codes.AddRange(acqChecklistSectionTypes);
codes.AddRange(acqChecklistItemStatusTypes);
codes.AddRange(agreementTypes);
codes.AddRange(interestHolderTypes);

var response = new JsonResult(codes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ private async Task HandleExceptionAsync(HttpContext context, Exception ex)

_logger.LogError(ex, "User override required to complete this action.");
}
else if (ex is ForeignKeyDependencyException)
{
var exception = ex as ForeignKeyDependencyException;
code = HttpStatusCode.Conflict;
message = exception.Message;
errorCode = null;

_logger.LogError(ex, "User deleting a foreign key dependency");
}
else if (ex is ApiHttpRequestException)
{
var exception = ex as ApiHttpRequestException;
Expand Down
28 changes: 28 additions & 0 deletions source/backend/api/Mapping/Lookup/LookupMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.Name, src => src.DistrictName)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Map(dest => dest.Type, src => src.GetType().Name);

config.NewConfig<Entity.PimsFinancialActivityCode, Model.LookupModel>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.Code, src => src.Code)
.Map(dest => dest.Name, src => src.Description)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Map(dest => dest.Type, src => src.GetType().Name);

config.NewConfig<Entity.PimsChartOfAccountsCode, Model.LookupModel>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.Code, src => src.Code)
.Map(dest => dest.Name, src => src.Description)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Map(dest => dest.Type, src => src.GetType().Name);

config.NewConfig<Entity.PimsResponsibilityCode, Model.LookupModel>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.Code, src => src.Code)
.Map(dest => dest.Name, src => src.Description)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Map(dest => dest.Type, src => src.GetType().Name);

config.NewConfig<Entity.PimsYearlyFinancialCode, Model.LookupModel>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.Code, src => src.Code)
.Map(dest => dest.Name, src => src.Description)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Map(dest => dest.Type, src => src.GetType().Name);
}
}
}
Loading

0 comments on commit 0cb3947

Please sign in to comment.