Skip to content

Commit edd9538

Browse files
authored
Merge pull request #681 from bcgov/yj
feat(dss-359)
2 parents e456fe7 + 96730c9 commit edd9538

File tree

8 files changed

+129
-0
lines changed

8 files changed

+129
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* Sprint 15 View Changes to STR DSS */
2+
3+
drop view if exists dss_platform_vw;
4+
5+
CREATE OR REPLACE VIEW dss_platform_vw AS
6+
SELECT do2.organization_id
7+
, do2.organization_cd
8+
, do2.organization_nm
9+
, do2.managing_organization_id
10+
, do2.upd_dtm
11+
, do2.upd_user_guid
12+
, docp.organization_contact_person_id as notice_of_takedown_contact_id
13+
, docp.email_address_dsc as notice_of_takedown_contact_email
14+
, docp2.organization_contact_person_id as takedown_request_contact_id
15+
, docp2.email_address_dsc as takedown_request_contact_email
16+
FROM dss_organization do2
17+
left join dss_organization_contact_person docp on docp.contacted_through_organization_id = do2.organization_id and docp.email_message_type = 'Notice of Takedown'
18+
left join dss_organization_contact_person docp2 on docp2.contacted_through_organization_id = do2.organization_id and docp2.email_message_type = 'Takedown Request'
19+
where do2.organization_type = 'Platform';

server/StrDss.Api/Controllers/OrganizationsController.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,15 @@ public async Task<ActionResult<StrRequirementsDto>> GetStrRequirements(double lo
7777

7878
return Ok(await _orgService.GetStrRequirements(longitude, latitude));
7979
}
80+
81+
82+
[ApiAuthorize()]
83+
[HttpGet("platforms")]
84+
public async Task<ActionResult> GetPlatforms(int pageSize = 10, int pageNumber = 1, string orderBy = "OrganizationNm", string direction = "asc")
85+
{
86+
var platforms = await _orgService.GetPlatforms(pageSize, pageNumber, orderBy, direction);
87+
return Ok(platforms);
88+
}
89+
8090
}
8191
}

server/StrDss.Data/Entities/DssDbContext.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public DssDbContext(DbContextOptions<DssDbContext> options)
3131

3232
public virtual DbSet<DssPhysicalAddress> DssPhysicalAddresses { get; set; }
3333

34+
public virtual DbSet<DssPlatformVw> DssPlatformVws { get; set; }
35+
3436
public virtual DbSet<DssRentalListing> DssRentalListings { get; set; }
3537

3638
public virtual DbSet<DssRentalListingContact> DssRentalListingContacts { get; set; }
@@ -658,6 +660,32 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
658660
.HasConstraintName("dss_physical_address_fk_replaced_by");
659661
});
660662

663+
modelBuilder.Entity<DssPlatformVw>(entity =>
664+
{
665+
entity
666+
.HasNoKey()
667+
.ToView("dss_platform_vw");
668+
669+
entity.Property(e => e.ManagingOrganizationId).HasColumnName("managing_organization_id");
670+
entity.Property(e => e.NoticeOfTakedownContactEmail)
671+
.HasMaxLength(320)
672+
.HasColumnName("notice_of_takedown_contact_email");
673+
entity.Property(e => e.NoticeOfTakedownContactId).HasColumnName("notice_of_takedown_contact_id");
674+
entity.Property(e => e.OrganizationCd)
675+
.HasMaxLength(25)
676+
.HasColumnName("organization_cd");
677+
entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
678+
entity.Property(e => e.OrganizationNm)
679+
.HasMaxLength(250)
680+
.HasColumnName("organization_nm");
681+
entity.Property(e => e.TakedownRequestContactEmail)
682+
.HasMaxLength(320)
683+
.HasColumnName("takedown_request_contact_email");
684+
entity.Property(e => e.TakedownRequestContactId).HasColumnName("takedown_request_contact_id");
685+
entity.Property(e => e.UpdDtm).HasColumnName("upd_dtm");
686+
entity.Property(e => e.UpdUserGuid).HasColumnName("upd_user_guid");
687+
});
688+
661689
modelBuilder.Entity<DssRentalListing>(entity =>
662690
{
663691
entity.HasKey(e => e.RentalListingId).HasName("dss_rental_listing_pk");
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace StrDss.Data.Entities;
5+
6+
public partial class DssPlatformVw
7+
{
8+
public long? OrganizationId { get; set; }
9+
10+
public string? OrganizationCd { get; set; }
11+
12+
public string? OrganizationNm { get; set; }
13+
14+
public long? ManagingOrganizationId { get; set; }
15+
16+
public DateTime? UpdDtm { get; set; }
17+
18+
public Guid? UpdUserGuid { get; set; }
19+
20+
public long? NoticeOfTakedownContactId { get; set; }
21+
22+
public string? NoticeOfTakedownContactEmail { get; set; }
23+
24+
public long? TakedownRequestContactId { get; set; }
25+
26+
public string? TakedownRequestContactEmail { get; set; }
27+
}

server/StrDss.Data/Mappings/EntityToModelProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public EntityToModelProfile()
5252

5353
CreateMap<DssBusinessLicence, BizLicenceSearchDto>();
5454
CreateMap<DssOrganization, PlatformCreateDto>();
55+
CreateMap<DssPlatformVw, PlatformViewDto>();
5556
}
5657
}
5758
}

server/StrDss.Data/Repositories/OrganizationRepository.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using StrDss.Data.Entities;
1010
using StrDss.Model;
1111
using StrDss.Model.OrganizationDtos;
12+
using StrDss.Model.RentalReportDtos;
1213

1314
namespace StrDss.Data.Repositories
1415
{
@@ -22,6 +23,7 @@ public interface IOrganizationRepository
2223
Task<long?> GetContainingOrganizationId(Point point);
2324
Task<long?> GetManagingOrgId(long orgId);
2425
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
26+
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
2527
}
2628
public class OrganizationRepository : RepositoryBase<DssOrganization>, IOrganizationRepository
2729
{
@@ -147,5 +149,20 @@ FROM dss_organization
147149

148150
return strRequirement;
149151
}
152+
153+
public async Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction)
154+
{
155+
var query = _dbContext.DssPlatformVws.AsNoTracking().Where(x => x.ManagingOrganizationId == null);
156+
157+
var platforms = await Page<DssPlatformVw, PlatformViewDto>(query, pageSize, pageNumber, orderBy, direction);
158+
159+
foreach (var platform in platforms.SourceList)
160+
{
161+
platform.Subsidiaries = _mapper.Map <List<PlatformViewDto>>
162+
(await _dbContext.DssPlatformVws.AsNoTracking().Where(x => x.ManagingOrganizationId == platform.OrganizationId).ToListAsync());
163+
}
164+
165+
return platforms;
166+
}
150167
}
151168
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace StrDss.Model.OrganizationDtos
2+
{
3+
public class PlatformViewDto
4+
{
5+
public PlatformViewDto()
6+
{
7+
Subsidiaries = new List<PlatformViewDto>();
8+
}
9+
10+
public long OrganizationId { get; set; }
11+
public string OrganizationCd { get; set; } = null!;
12+
public string OrganizationNm { get; set; } = null!;
13+
public DateTime UpdDtm { get; set; }
14+
public Guid? UpdUserGuid { get; set; }
15+
public long NoticeOfTakedownContactId { get; set; }
16+
public string NoticeOfTakedownContactEmail { get; set; }
17+
public long TakedownRequestContactId { get; set; }
18+
public string TakedownRequestContactEmail { get; set; }
19+
public virtual ICollection<PlatformViewDto> Subsidiaries { get; set; }
20+
}
21+
}

server/StrDss.Service/OrganizationService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public interface IOrganizationService
1818
Task<OrganizationDto?> GetOrganizationByIdAsync(long id);
1919
Task<long?> GetContainingOrganizationId(Point point);
2020
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
21+
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
2122
}
2223
public class OrganizationService : ServiceBase, IOrganizationService
2324
{
@@ -59,5 +60,10 @@ public async Task<List<DropdownNumDto>> GetOrganizationsDropdownAsync(string? ty
5960
{
6061
return await _orgRepo.GetStrRequirements(longitude, latitude);
6162
}
63+
64+
public async Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction)
65+
{
66+
return await _orgRepo.GetPlatforms(pageSize, pageNumber, orderBy, direction);
67+
}
6268
}
6369
}

0 commit comments

Comments
 (0)