Skip to content

Commit

Permalink
Merge pull request #754 from bcgov/yj
Browse files Browse the repository at this point in the history
Yj
  • Loading branch information
ychung-mot authored Oct 28, 2024
2 parents e17ce24 + c5a2fd3 commit c7558dd
Show file tree
Hide file tree
Showing 15 changed files with 311 additions and 109 deletions.
15 changes: 15 additions & 0 deletions database/ddl/STR_DSS_Views_Sprint_17.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Sprint 17 View Changes to STR DSS */

drop view if exists dss_local_gov_vw;

CREATE OR REPLACE VIEW dss_local_gov_vw AS
SELECT do2.organization_id
, do2.organization_type
, do2.organization_cd
, do2.organization_nm
, do2.local_government_type
, lgt.local_government_type_nm
, do2.business_licence_format_txt
FROM dss_organization do2
left join dss_local_government_type lgt on lgt.local_government_type = do2.local_government_type
where do2.organization_type = 'LG';
136 changes: 41 additions & 95 deletions postman/str-dss.postman_collection.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions server/StrDss.Api/Controllers/OrganizationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ public OrganizationsController(ICurrentUser currentUser, IMapper mapper, IConfig
{
_orgService = orgService;
}
[ApiAuthorize]
[HttpGet("localgovtypes", Name = "GetLocalGovTypes")]
public async Task<ActionResult<List<LocalGovTypeDto>>> GetLocalGovTypes()
{
return Ok(await _orgService.GetLocalGovTypesAsync());
}

[ApiAuthorize]
[HttpGet("economicregions", Name = "GetEconomicRegions")]
public async Task<ActionResult<List<EconomicRegionDto>>> GetEconomicRegions()
{
return Ok(await _orgService.GetEconomicRegionsAsync());
}

[ApiAuthorize]
[HttpGet("types", Name = "GetOrganizationTypes")]
Expand Down
91 changes: 87 additions & 4 deletions server/StrDss.Data/Entities/DssDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ public DssDbContext(DbContextOptions<DssDbContext> options)

public virtual DbSet<DssBusinessLicenceStatusType> DssBusinessLicenceStatusTypes { get; set; }

public virtual DbSet<DssEconomicRegion> DssEconomicRegions { get; set; }

public virtual DbSet<DssEmailMessage> DssEmailMessages { get; set; }

public virtual DbSet<DssEmailMessageType> DssEmailMessageTypes { get; set; }

public virtual DbSet<DssListingStatusType> DssListingStatusTypes { get; set; }

public virtual DbSet<DssLocalGovVw> DssLocalGovVws { get; set; }

public virtual DbSet<DssLocalGovernmentType> DssLocalGovernmentTypes { get; set; }

public virtual DbSet<DssOrganization> DssOrganizations { get; set; }

public virtual DbSet<DssOrganizationContactPerson> DssOrganizationContactPeople { get; set; }
Expand Down Expand Up @@ -253,6 +259,25 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasColumnName("licence_status_type_nm");
});

modelBuilder.Entity<DssEconomicRegion>(entity =>
{
entity.HasKey(e => e.EconomicRegionDsc).HasName("dss_economic_region_pk");

entity.ToTable("dss_economic_region", tb => tb.HasComment("A geographic classification of LOCAL GOVERNMENT SUBDIVISION used for sorting and grouping of members"));

entity.Property(e => e.EconomicRegionDsc)
.HasMaxLength(100)
.HasComment("System-consistent code (e.g. Northeast, Cariboo)")
.HasColumnName("economic_region_dsc");
entity.Property(e => e.EconomicRegionNm)
.HasMaxLength(250)
.HasComment("Business term for the ECONOMIC REGION (e.g. Northeast, Cariboo)")
.HasColumnName("economic_region_nm");
entity.Property(e => e.EconomicRegionSortNo)
.HasComment("Relative order in which the business prefers to see the ECONOMIC REGION listed")
.HasColumnName("economic_region_sort_no");
});

modelBuilder.Entity<DssEmailMessage>(entity =>
{
entity.HasKey(e => e.EmailMessageId).HasName("dss_email_message_pk");
Expand Down Expand Up @@ -411,6 +436,52 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasColumnName("listing_status_type_nm");
});

modelBuilder.Entity<DssLocalGovVw>(entity =>
{
entity
.HasNoKey()
.ToView("dss_local_gov_vw");

entity.Property(e => e.BusinessLicenceFormatTxt)
.HasMaxLength(50)
.HasColumnName("business_licence_format_txt");
entity.Property(e => e.LocalGovernmentType)
.HasMaxLength(50)
.HasColumnName("local_government_type");
entity.Property(e => e.LocalGovernmentTypeNm)
.HasMaxLength(250)
.HasColumnName("local_government_type_nm");
entity.Property(e => e.OrganizationCd)
.HasMaxLength(25)
.HasColumnName("organization_cd");
entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
entity.Property(e => e.OrganizationNm)
.HasMaxLength(250)
.HasColumnName("organization_nm");
entity.Property(e => e.OrganizationType)
.HasMaxLength(25)
.HasColumnName("organization_type");
});

modelBuilder.Entity<DssLocalGovernmentType>(entity =>
{
entity.HasKey(e => e.LocalGovernmentType).HasName("dss_local_government_type_pk");

entity.ToTable("dss_local_government_type", tb => tb.HasComment("A sub-type of local government organization used for sorting and grouping of members"));

entity.Property(e => e.LocalGovernmentType)
.HasMaxLength(50)
.HasComment("System-consistent code (e.g. Municipality, First Nations Community)")
.HasColumnName("local_government_type");
entity.Property(e => e.LocalGovernmentTypeNm)
.HasMaxLength(250)
.HasComment("Business term for for the local government type (e.g. Municipality, First Nations Community)")
.HasColumnName("local_government_type_nm");
entity.Property(e => e.LocalGovernmentTypeSortNo)
.HasComment("Relative order in which the business prefers to see the LOCAL GOVERNMENT TYPE listed")
.HasColumnName("local_government_type_sort_no");
});

modelBuilder.Entity<DssOrganization>(entity =>
{
entity.HasKey(e => e.OrganizationId).HasName("dss_organization_pk");
Expand All @@ -430,9 +501,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.AreaGeometry)
.HasComment("the multipolygon shape identifying the boundaries of a local government subdivision")
.HasColumnName("area_geometry");
entity.Property(e => e.BusinessLicenceFormatTxt)
.HasMaxLength(50)
.HasComment("A free form indication of how BUSINESS NUMBER is laid out for a LOCAL GOVERNMENT ORGANIZATION")
.HasColumnName("business_licence_format_txt");
entity.Property(e => e.EconomicRegionDsc)
.HasMaxLength(100)
.HasComment("A free form description of the economic region to which a Local Government Subdivision belongs")
.HasComment("Foreign key for a Local Government Subdivision")
.HasColumnName("economic_region_dsc");
entity.Property(e => e.IsActive)
.HasComment("Indicates whether the ORGANIZATION is currently available for new associations")
Expand All @@ -447,11 +522,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasComment("Indicates whether a LOCAL GOVERNMENT SUBDIVISION is subject to Provincial Principal Residence Short Term Rental restrictions")
.HasColumnName("is_principal_residence_required");
entity.Property(e => e.IsStrProhibited)
.HasComment("Indicates whether a LOCAL GOVERNMENT ORGANIZATION entirely prohibits short term housing rentals")
.HasComment("Indicates whether a LOCAL GOVERNMENT SUBDIVISION entirely prohibits short term housing rentals")
.HasColumnName("is_str_prohibited");
entity.Property(e => e.LocalGovernmentType)
.HasMaxLength(50)
.HasComment("A sub-type of local government organization used for sorting and grouping of members")
.HasComment("Foreign key for a LOCAL GOVERNMENT")
.HasColumnName("local_government_type");
entity.Property(e => e.ManagingOrganizationId)
.HasComment("Self-referential hierarchical foreign key")
Expand All @@ -470,7 +545,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasColumnName("organization_type");
entity.Property(e => e.PlatformType)
.HasMaxLength(25)
.HasComment("Foreign key")
.HasComment("Foreign key for a RENTAL PLATFORM")
.HasColumnName("platform_type");
entity.Property(e => e.UpdDtm)
.HasComment("Trigger-updated timestamp of last change")
Expand All @@ -479,6 +554,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasComment("The globally unique identifier (assigned by the identity provider) for the most recent user to record a change")
.HasColumnName("upd_user_guid");

entity.HasOne(d => d.EconomicRegionDscNavigation).WithMany(p => p.DssOrganizations)
.HasForeignKey(d => d.EconomicRegionDsc)
.HasConstraintName("dss_organization_fk_within");

entity.HasOne(d => d.LocalGovernmentTypeNavigation).WithMany(p => p.DssOrganizations)
.HasForeignKey(d => d.LocalGovernmentType)
.HasConstraintName("dss_organization_fk_administered_as");

entity.HasOne(d => d.ManagingOrganization).WithMany(p => p.InverseManagingOrganization)
.HasForeignKey(d => d.ManagingOrganizationId)
.HasConstraintName("dss_organization_fk_managed_by");
Expand Down
27 changes: 27 additions & 0 deletions server/StrDss.Data/Entities/DssEconomicRegion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;

namespace StrDss.Data.Entities;

/// <summary>
/// A geographic classification of LOCAL GOVERNMENT SUBDIVISION used for sorting and grouping of members
/// </summary>
public partial class DssEconomicRegion
{
/// <summary>
/// System-consistent code (e.g. Northeast, Cariboo)
/// </summary>
public string EconomicRegionDsc { get; set; } = null!;

/// <summary>
/// Business term for the ECONOMIC REGION (e.g. Northeast, Cariboo)
/// </summary>
public string EconomicRegionNm { get; set; } = null!;

/// <summary>
/// Relative order in which the business prefers to see the ECONOMIC REGION listed
/// </summary>
public short? EconomicRegionSortNo { get; set; }

public virtual ICollection<DssOrganization> DssOrganizations { get; set; } = new List<DssOrganization>();
}
21 changes: 21 additions & 0 deletions server/StrDss.Data/Entities/DssLocalGovVw.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;

namespace StrDss.Data.Entities;

public partial class DssLocalGovVw
{
public long? OrganizationId { get; set; }

public string? OrganizationType { get; set; }

public string? OrganizationCd { get; set; }

public string? OrganizationNm { get; set; }

public string? LocalGovernmentType { get; set; }

public string? LocalGovernmentTypeNm { get; set; }

public string? BusinessLicenceFormatTxt { get; set; }
}
27 changes: 27 additions & 0 deletions server/StrDss.Data/Entities/DssLocalGovernmentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;

namespace StrDss.Data.Entities;

/// <summary>
/// A sub-type of local government organization used for sorting and grouping of members
/// </summary>
public partial class DssLocalGovernmentType
{
/// <summary>
/// System-consistent code (e.g. Municipality, First Nations Community)
/// </summary>
public string LocalGovernmentType { get; set; } = null!;

/// <summary>
/// Business term for for the local government type (e.g. Municipality, First Nations Community)
/// </summary>
public string LocalGovernmentTypeNm { get; set; } = null!;

/// <summary>
/// Relative order in which the business prefers to see the LOCAL GOVERNMENT TYPE listed
/// </summary>
public short? LocalGovernmentTypeSortNo { get; set; }

public virtual ICollection<DssOrganization> DssOrganizations { get; set; } = new List<DssOrganization>();
}
17 changes: 13 additions & 4 deletions server/StrDss.Data/Entities/DssOrganization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ public partial class DssOrganization
public bool? IsBusinessLicenceRequired { get; set; }

/// <summary>
/// A free form description of the economic region to which a Local Government Subdivision belongs
/// Foreign key for a Local Government Subdivision
/// </summary>
public string? EconomicRegionDsc { get; set; }

/// <summary>
/// A sub-type of local government organization used for sorting and grouping of members
/// Foreign key for a LOCAL GOVERNMENT
/// </summary>
public string? LocalGovernmentType { get; set; }

/// <summary>
/// Indicates whether a LOCAL GOVERNMENT ORGANIZATION entirely prohibits short term housing rentals
/// Indicates whether a LOCAL GOVERNMENT SUBDIVISION entirely prohibits short term housing rentals
/// </summary>
public bool? IsStrProhibited { get; set; }

Expand All @@ -85,10 +85,15 @@ public partial class DssOrganization
public bool? IsActive { get; set; }

/// <summary>
/// Foreign key
/// Foreign key for a RENTAL PLATFORM
/// </summary>
public string? PlatformType { get; set; }

/// <summary>
/// A free form indication of how BUSINESS NUMBER is laid out for a LOCAL GOVERNMENT ORGANIZATION
/// </summary>
public string? BusinessLicenceFormatTxt { get; set; }

public virtual ICollection<DssBusinessLicence> DssBusinessLicences { get; set; } = new List<DssBusinessLicence>();

public virtual ICollection<DssEmailMessage> DssEmailMessageInvolvedInOrganizations { get; set; } = new List<DssEmailMessage>();
Expand All @@ -109,8 +114,12 @@ public partial class DssOrganization

public virtual ICollection<DssUserIdentity> DssUserIdentities { get; set; } = new List<DssUserIdentity>();

public virtual DssEconomicRegion? EconomicRegionDscNavigation { get; set; }

public virtual ICollection<DssOrganization> InverseManagingOrganization { get; set; } = new List<DssOrganization>();

public virtual DssLocalGovernmentType? LocalGovernmentTypeNavigation { get; set; }

public virtual DssOrganization? ManagingOrganization { get; set; }

public virtual DssOrganizationType OrganizationTypeNavigation { get; set; } = null!;
Expand Down
5 changes: 3 additions & 2 deletions server/StrDss.Data/Mappings/EntityToModelProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ public EntityToModelProfile()
CreateMap<DssPlatformVw, PlatformViewDto>();
CreateMap<DssPlatformType, PlatformTypeDto>();

CreateMap<DssOrganization, LocalGovViewDto>();
CreateMap<DssLocalGovVw, LocalGovViewDto>();
CreateMap<DssOrganization, JurisdictionsViewDto>();

CreateMap<DssEconomicRegion, EconomicRegionDto>();
CreateMap<DssLocalGovernmentType, LocalGovTypeDto>();
}
}
}
26 changes: 23 additions & 3 deletions server/StrDss.Data/Repositories/OrganizationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace StrDss.Data.Repositories
{
public interface IOrganizationRepository
{
Task<List<LocalGovTypeDto>> GetLocalGovTypesAsync();
Task<List<EconomicRegionDto>> GetEconomicRegionsAsync();
Task<List<OrganizationTypeDto>> GetOrganizationTypesAsnc();
Task<List<OrganizationDto>> GetOrganizationsAsync(string? type);
Task<OrganizationDto?> GetOrganizationByIdAsync(long orgId);
Expand Down Expand Up @@ -42,6 +44,25 @@ public OrganizationRepository(DssDbContext dbContext, IMapper mapper, ICurrentUs
{
_config = config;
}
public async Task<List<LocalGovTypeDto>> GetLocalGovTypesAsync()
{
var types = _mapper.Map<List<LocalGovTypeDto>>(
await _dbContext.DssLocalGovernmentTypes.AsNoTracking()
.OrderBy(x => x.LocalGovernmentTypeSortNo)
.ToListAsync());

return types;
}

public async Task<List<EconomicRegionDto>> GetEconomicRegionsAsync()
{
var regions = _mapper.Map<List<EconomicRegionDto>>(
await _dbContext.DssEconomicRegions.AsNoTracking()
.OrderBy(x => x.EconomicRegionSortNo)
.ToListAsync());

return regions;
}

public async Task<List<OrganizationTypeDto>> GetOrganizationTypesAsnc()
{
Expand Down Expand Up @@ -297,10 +318,9 @@ public async Task UpdatePlatformSubAsync(PlatformSubUpdateDto dto)

public async Task<PagedDto<LocalGovViewDto>> GetJurisdictions(int pageSize, int pageNumber, string orderBy, string direction)
{
var query = _dbSet.AsNoTracking()
.Where(x => x.OrganizationType == OrganizationTypes.LG && x.ManagingOrganizationId == null);
var query = _dbContext.DssLocalGovVws.AsNoTracking().AsQueryable();

var lgs = await Page<DssOrganization, LocalGovViewDto>(query, pageSize, pageNumber, orderBy, direction);
var lgs = await Page<DssLocalGovVw, LocalGovViewDto>(query, pageSize, pageNumber, orderBy, direction);

foreach (var lg in lgs.SourceList)
{
Expand Down
14 changes: 14 additions & 0 deletions server/StrDss.Model/OrganizationDtos/EconomicRegionDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Text.Json.Serialization;

namespace StrDss.Model.OrganizationDtos
{
public class EconomicRegionDto
{
[JsonPropertyName("value")]
public string EconomicRegionDsc { get; set; } = null!;
[JsonPropertyName("label")]
public string EconomicRegionNm { get; set; } = null!;
[JsonPropertyName("sort")]
public short? EconomicRegionSortNo { get; set; }
}
}
Loading

0 comments on commit c7558dd

Please sign in to comment.