Skip to content

Commit

Permalink
chore: scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
ychung-mot committed Oct 28, 2024
1 parent e17ce24 commit edc1ceb
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 106 deletions.
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
66 changes: 61 additions & 5 deletions server/StrDss.Data/Entities/DssDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ 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<DssLocalGovernmentType> DssLocalGovernmentTypes { get; set; }

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

public virtual DbSet<DssOrganizationContactPerson> DssOrganizationContactPeople { get; set; }
Expand Down Expand Up @@ -65,7 +69,9 @@ public DssDbContext(DbContextOptions<DssDbContext> options)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasPostgresExtension("postgis");
modelBuilder
.HasPostgresExtension("pgcrypto")
.HasPostgresExtension("postgis");

modelBuilder.Entity<DssAccessRequestStatus>(entity =>
{
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,25 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasColumnName("listing_status_type_nm");
});

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 +474,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 +495,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 +518,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 +527,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>();
}
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
3 changes: 2 additions & 1 deletion server/StrDss.Data/Mappings/EntityToModelProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public EntityToModelProfile()

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

CreateMap<DssEconomicRegion, EconomicRegionDto>();
CreateMap<DssLocalGovernmentType, LocalGovTypeDto>();
}
}
}
21 changes: 21 additions & 0 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
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; }
}
}
14 changes: 14 additions & 0 deletions server/StrDss.Model/OrganizationDtos/LocalGovTypeDto.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 LocalGovTypeDto
{
[JsonPropertyName("value")]
public string LocalGovernmentType { get; set; } = null!;
[JsonPropertyName("label")]
public string LocalGovernmentTypeNm { get; set; } = null!;
[JsonPropertyName("sort")]
public short? LocalGovernmentTypeSortNo { get; set; }
}
}
2 changes: 2 additions & 0 deletions server/StrDss.Model/OrganizationDtos/OrganizationDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class OrganizationDto
public bool? IsPrincipalResidenceRequired { get; set; }
public bool? IsBusinessLicenceRequired { get; set; }
public bool? IsStrProhibited { get; set; }
public string? PlatformType { get; set; }
public string? BusinessLicenceFormatTxt { get; set; }
public virtual ICollection<ContactPersonDto> ContactPeople { get; set; } = new List<ContactPersonDto>();

}
Expand Down
11 changes: 10 additions & 1 deletion server/StrDss.Service/OrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace StrDss.Service
{
public interface IOrganizationService
{
Task<List<LocalGovTypeDto>> GetLocalGovTypesAsync();
Task<List<EconomicRegionDto>> GetEconomicRegionsAsync();
Task<List<OrganizationTypeDto>> GetOrganizationTypesAsnc();
Task<List<OrganizationDto>> GetOrganizationsAsync(string? type);
Task<List<DropdownNumDto>> GetOrganizationsDropdownAsync(string? type);
Expand Down Expand Up @@ -41,7 +43,14 @@ public OrganizationService(ICurrentUser currentUser, IFieldValidatorService vali
_orgRepo = orgRepo;
_codeSetRepo = codeSetRep;
}

public async Task<List<LocalGovTypeDto>> GetLocalGovTypesAsync()
{
return await _orgRepo.GetLocalGovTypesAsync();
}
public async Task<List<EconomicRegionDto>> GetEconomicRegionsAsync()
{
return await _orgRepo.GetEconomicRegionsAsync();
}
public async Task<List<OrganizationTypeDto>> GetOrganizationTypesAsnc()
{
return await _orgRepo.GetOrganizationTypesAsnc();
Expand Down

0 comments on commit edc1ceb

Please sign in to comment.