Skip to content

Commit

Permalink
chore: local gov view
Browse files Browse the repository at this point in the history
  • Loading branch information
ychung-mot committed Oct 28, 2024
1 parent a9e96b6 commit c5a2fd3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
33 changes: 30 additions & 3 deletions server/StrDss.Data/Entities/DssDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public DssDbContext(DbContextOptions<DssDbContext> options)

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; }
Expand Down Expand Up @@ -69,9 +71,7 @@ public DssDbContext(DbContextOptions<DssDbContext> options)

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

modelBuilder.Entity<DssAccessRequestStatus>(entity =>
{
Expand Down Expand Up @@ -436,6 +436,33 @@ 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");
Expand Down
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; }
}
2 changes: 1 addition & 1 deletion server/StrDss.Data/Mappings/EntityToModelProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public EntityToModelProfile()
CreateMap<DssPlatformVw, PlatformViewDto>();
CreateMap<DssPlatformType, PlatformTypeDto>();

CreateMap<DssOrganization, LocalGovViewDto>();
CreateMap<DssLocalGovVw, LocalGovViewDto>();
CreateMap<DssOrganization, JurisdictionsViewDto>();
CreateMap<DssEconomicRegion, EconomicRegionDto>();
CreateMap<DssLocalGovernmentType, LocalGovTypeDto>();
Expand Down
5 changes: 2 additions & 3 deletions server/StrDss.Data/Repositories/OrganizationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,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
1 change: 1 addition & 0 deletions server/StrDss.Model/OrganizationDtos/LocalGovViewDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public LocalGovViewDto()
public long OrganizationId { get; set; }
public string OrganizationNm { get; set; } = "";
public string LocalGovernmentType { get; set; } = "";
public string LocalGovernmentTypeNm { get; set; } = "";
public string OrganizationCd { get; set; } = "";
public string BusinessLicenceFormatTxt { get; set; } = "";
public virtual ICollection<JurisdictionsViewDto> Jurisdictions { get; set; }
Expand Down

0 comments on commit c5a2fd3

Please sign in to comment.