Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSP-6865 Property Management summary #3499

Merged
merged 25 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class PropertyController : ControllerBase
#region Variables
private readonly IPropertyRepository _propertyRepository;
private readonly IPropertyService _propertyService;
private readonly IPropertyLeaseRepository _propertyLeaseRepository;
private readonly IMapper _mapper;
#endregion

Expand All @@ -36,14 +35,12 @@ public class PropertyController : ControllerBase
/// </summary>
/// <param name="propertyRepository"></param>
/// <param name="propertyService"></param>
/// <param name="propertyLeaseRepository"></param>
/// <param name="mapper"></param>
///
public PropertyController(IPropertyRepository propertyRepository, IPropertyService propertyService, IPropertyLeaseRepository propertyLeaseRepository, IMapper mapper)
public PropertyController(IPropertyRepository propertyRepository, IPropertyService propertyService, IMapper mapper)
{
_propertyRepository = propertyRepository;
_propertyService = propertyService;
_propertyLeaseRepository = propertyLeaseRepository;
_mapper = mapper;
}
#endregion
Expand All @@ -66,22 +63,6 @@ public IActionResult GetPropertyAssociationsWithId(long id)
return new JsonResult(_mapper.Map<PropertyAssociationModel>(property));
}

/// <summary>
/// Get all associated leases for the specified unique property 'id'.
/// </summary>
/// <returns></returns>
[HttpGet("{id}/leases")]
[HasPermission(Permissions.PropertyView)]
[HasPermission(Permissions.LeaseView)]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<Api.Models.Concepts.PropertyLeaseModel>), 200)]
[SwaggerOperation(Tags = new[] { "property" })]
public IActionResult GetPropertyLeases(long propertyId)
{
var propertyLeases = _propertyLeaseRepository.GetAllByPropertyId(propertyId);

return new JsonResult(_mapper.Map<List<Api.Models.Concepts.PropertyLeaseModel>>(propertyLeases));
}
#endregion

#region Concept Endpoints
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
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.Property.Controllers
{
/// <summary>
/// PropertyManagementController class, provides endpoints for interacting with property management information.
/// </summary>
[Authorize]
[ApiController]
[ApiVersion("1.0")]
[Area("properties")]
[Route("v{version:apiVersion}/[area]")]
[Route("[area]")]
public class PropertyManagementController : ControllerBase
{
#region Variables
private readonly IPropertyService _propertyService;
private readonly IMapper _mapper;
#endregion

/// <summary>
/// Creates a new instance of a PropertyManagementController class, initializes it with the specified arguments.
/// </summary>
/// <param name="propertyService"></param>
/// <param name="mapper"></param>
public PropertyManagementController(IPropertyService propertyService, IMapper mapper)
{
_propertyService = propertyService;
_mapper = mapper;
}

Check warning on line 38 in source/backend/api/Areas/Property/Controllers/PropertyManagementController.cs

View check run for this annotation

Codecov / codecov/patch

source/backend/api/Areas/Property/Controllers/PropertyManagementController.cs#L34-L38

Added lines #L34 - L38 were not covered by tests

/// <summary>
/// Get the property management information for the property with 'propertyId'.
/// </summary>
/// <returns></returns>
[HttpGet("{propertyId}/management")]
[HasPermission(Permissions.ManagementView)]
[Produces("application/json")]
[ProducesResponseType(typeof(PropertyManagementModel), 200)]
[SwaggerOperation(Tags = new[] { "property" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult GetPropertyManagement(long propertyId)
{
return new JsonResult(_propertyService.GetPropertyManagement(propertyId));
}

Check warning on line 53 in source/backend/api/Areas/Property/Controllers/PropertyManagementController.cs

View check run for this annotation

Codecov / codecov/patch

source/backend/api/Areas/Property/Controllers/PropertyManagementController.cs#L51-L53

Added lines #L51 - L53 were not covered by tests

/// <summary>
/// Update the specified property management information.
/// </summary>
/// <returns></returns>
[HttpPut("{propertyId}/management")]
[HasPermission(Permissions.ManagementEdit)]
[Produces("application/json")]
[ProducesResponseType(typeof(PropertyManagementModel), 200)]
[SwaggerOperation(Tags = new[] { "property" })]
[TypeFilter(typeof(NullJsonResultFilter))]
public IActionResult UpdatePropertyManagement([FromBody] PropertyManagementModel propertyManagementModel)
{
var propertyEntity = _mapper.Map<Pims.Dal.Entities.PimsProperty>(propertyManagementModel);
return new JsonResult(_propertyService.UpdatePropertyManagement(propertyEntity));
}

Check warning on line 69 in source/backend/api/Areas/Property/Controllers/PropertyManagementController.cs

View check run for this annotation

Codecov / codecov/patch

source/backend/api/Areas/Property/Controllers/PropertyManagementController.cs#L66-L69

Added lines #L66 - L69 were not covered by tests
}
}
2 changes: 2 additions & 0 deletions source/backend/api/Controllers/LookupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public IActionResult GetAll()
var propertyRoadTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyRoadTypes());
var volumeUnitTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyVolumeUnitTypes());
var propertyVolumetricTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyVolumetricTypes());
var propertyManagementPurposeTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPropertyManagementPurposeTypes());
var pphStatusType = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllPPHStatusType());
var documentStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllDocumentStatusTypes());
var acquisitionFileStatusTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllAcquisitionFileStatusTypes());
Expand Down Expand Up @@ -179,6 +180,7 @@ public IActionResult GetAll()
codes.AddRange(propertyRoadTypes);
codes.AddRange(volumeUnitTypes);
codes.AddRange(propertyVolumetricTypes);
codes.AddRange(propertyManagementPurposeTypes);
codes.AddRange(pphStatusType);
codes.AddRange(documentStatusTypes);
codes.AddRange(acquisitionFileStatusTypes);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Mapster;
using Entity = Pims.Dal.Entities;

namespace Pims.Api.Models.Concepts
{
public class PropertyManagementMap : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.NewConfig<Entity.PimsProperty, PropertyManagementModel>()
.Map(dest => dest.Id, src => src.Internal_Id)
.Map(dest => dest.ManagementPurposes, src => src.PimsPropPropPurposes)
.Map(dest => dest.AdditionalDetails, src => src.AdditionalDetails)
.Map(dest => dest.IsUtilitiesPayable, src => src.IsUtilitiesPayable)
.Map(dest => dest.IsTaxesPayable, src => src.IsTaxesPayable)
.Inherits<Entity.IBaseAppEntity, BaseAppModel>();

config.NewConfig<PropertyManagementModel, Entity.PimsProperty>()
.Map(dest => dest.Internal_Id, src => src.Id)
.Map(dest => dest.PimsPropPropPurposes, src => src.ManagementPurposes)
.Map(dest => dest.AdditionalDetails, src => src.AdditionalDetails)
.Map(dest => dest.IsUtilitiesPayable, src => src.IsUtilitiesPayable)
.Map(dest => dest.IsTaxesPayable, src => src.IsTaxesPayable)
.Inherits<BaseAppModel, Entity.IBaseAppEntity>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;

namespace Pims.Api.Models.Concepts
{
/// <summary>
/// PropertyManagementModel class, provides a model to represent the property management information.
/// </summary>
public class PropertyManagementModel : BaseAppModel
{
/// <summary>
/// get/set - The primary key to identify the property.
/// </summary>
public long Id { get; set; }

/// <summary>
/// get/set - The property management purposes.
/// </summary>
public IList<PropertyManagementPurposeModel> ManagementPurposes { get; set; }

/// <summary>
/// get/set - Additional details when property management purpose is OTHER.
/// </summary>
public string AdditionalDetails { get; set; }

/// <summary>
/// get/set - Whether utilities are payable for this property..
/// </summary>
public bool? IsUtilitiesPayable { get; set; }

/// <summary>
/// get/set - Whether taxes are payable for this property.
/// </summary>
public bool? IsTaxesPayable { get; set; }

/// <summary>
/// get/set - Whether this property has an "active lease".
/// </summary>
public bool IsLeaseActive { get; set; }

/// <summary>
/// get/set - Whether this property has an "active lease" that is expired.
/// </summary>
public bool IsLeaseExpired { get; set; }

/// <summary>
/// get/set - The expiry date on the active lease for this property (if any).
/// </summary>
public DateTime? LeaseExpiryDate { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ public void Register(TypeAdapterConfig config)
config.NewConfig<Entity.PimsPropPropPurpose, PropertyManagementPurposeModel>()
.Map(dest => dest.Id, src => src.Internal_Id)
.Map(dest => dest.PropertyId, src => src.PropertyId)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Map(dest => dest.PropertyPurposeTypeCode, src => src.PropertyPurposeTypeCodeNavigation)
.Inherits<Entity.IBaseAppEntity, BaseAppModel>();

config.NewConfig<PropertyManagementPurposeModel, Entity.PimsPropPropPurpose>()
.Map(dest => dest.Internal_Id, src => src.Id)
.Map(dest => dest.PropertyId, src => src.PropertyId)
.Map(dest => dest.IsDisabled, src => src.IsDisabled)
.Map(dest => dest.PropertyPurposeTypeCode, src => src.PropertyPurposeTypeCode.Id)
.Inherits<BaseAppModel, Entity.IBaseAppEntity>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public class PropertyManagementPurposeModel : BaseAppModel
/// </summary>
public long PropertyId { get; set; }

// TODO: Remove this from DB schema

/// <summary>
/// get/set - Whether this relationship is disabled.
/// </summary>
public bool IsDisabled { get; set; }

/// <summary>
/// get/set - The property purpose type code.
/// </summary>
Expand Down
9 changes: 0 additions & 9 deletions source/backend/api/Models/Concepts/Property/PropertyMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.SurplusDeclarationDate, src => src.SurplusDeclarationDate)
.Map(dest => dest.SurplusDeclarationType, src => src.SurplusDeclarationTypeCodeNavigation)

.Map(dest => dest.ManagementPurposes, src => src.PimsPropPropPurposes)
.Map(dest => dest.AdditionalDetails, src => src.AdditionalDetails)
.Map(dest => dest.IsUtilitiesPayable, src => src.IsUtilitiesPayable)
.Map(dest => dest.IsTaxesPayable, src => src.IsTaxesPayable)
.Inherits<Entity.IBaseEntity, Api.Models.BaseModel>();

config.NewConfig<PropertyModel, Entity.PimsProperty>()
Expand Down Expand Up @@ -114,11 +110,6 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.Zoning, src => src.Zoning)
.Map(dest => dest.ZoningPotential, src => src.ZoningPotential)

.Map(dest => dest.PimsPropPropPurposes, src => src.ManagementPurposes)
.Map(dest => dest.AdditionalDetails, src => src.AdditionalDetails)
.Map(dest => dest.IsUtilitiesPayable, src => src.IsUtilitiesPayable)
.Map(dest => dest.IsTaxesPayable, src => src.IsTaxesPayable)

.Inherits<BaseModel, Entity.IBaseEntity>();
}
}
Expand Down
22 changes: 0 additions & 22 deletions source/backend/api/Models/Concepts/Property/PropertyModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,6 @@ public class PropertyModel : BaseModel
public DateTime SurplusDeclarationDate { get; set; }
#endregion

#region Management
/// <summary>
/// get/set - The property management purposes.
/// </summary>
public IList<PropertyManagementPurposeModel> ManagementPurposes { get; set; }

/// <summary>
/// get/set - Additional details when property management purpose is OTHER.
/// </summary>
public string AdditionalDetails { get; set; }

/// <summary>
/// get/set - Whether utilities are payable for this property..
/// </summary>
public bool? IsUtilitiesPayable { get; set; }

/// <summary>
/// get/set - Whether taxes are payable for this property.
/// </summary>
public bool? IsTaxesPayable { get; set; }
#endregion

#endregion
}
}
5 changes: 5 additions & 0 deletions source/backend/api/Services/IPropertyService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Pims.Api.Models.Concepts;
using Pims.Dal.Entities;

namespace Pims.Api.Services
Expand All @@ -22,5 +23,9 @@ public interface IPropertyService
PimsPropertyContact UpdateContact(PimsPropertyContact propertyContact);

bool DeleteContact(long propertyContactId);

PropertyManagementModel GetPropertyManagement(long propertyId);

PropertyManagementModel UpdatePropertyManagement(PimsProperty property);
}
}
Loading
Loading