Skip to content

Commit a919ed9

Browse files
authored
Merge pull request #545 from bcgov/yj
feat: rental listing with biz license info
2 parents 2b61ad1 + 4363def commit a919ed9

File tree

11 files changed

+117
-13
lines changed

11 files changed

+117
-13
lines changed

database/ddl/STR_DSS_Views_Sprint_9.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ CREATE OR REPLACE VIEW dss_rental_listing_vw AS select drl.rental_listing_id
4848
, drl.bc_registry_no
4949
, demt.email_message_type_nm as last_action_nm
5050
, dem.message_delivery_dtm as last_action_dtm
51+
, dbl.business_licence_id
5152
FROM dss_rental_listing drl
5253
join dss_organization org on org.organization_id=drl.offering_organization_id
5354
LEFT JOIN dss_listing_status_type dlst on drl.listing_status_type=dlst.listing_status_type
@@ -56,4 +57,5 @@ left join dss_organization lgs on lgs.organization_id=dpa.containing_organizatio
5657
left join dss_organization lg on lgs.managing_organization_id=lg.organization_id
5758
LEFT JOIN dss_email_message dem on dem.email_message_id = (select msg.email_message_id from dss_email_message msg where msg.concerned_with_rental_listing_id=drl.rental_listing_id order by msg.message_delivery_dtm desc limit 1)
5859
LEFT JOIN dss_email_message_type demt on dem.email_message_type=demt.email_message_type
60+
LEFT join dss_business_licence dbl on drl.governing_business_licence_id = dbl.business_licence_id
5961
where drl.including_rental_listing_report_id is null;

postman/str-dss.postman_collection.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -992,14 +992,14 @@
992992
"method": "GET",
993993
"header": [],
994994
"url": {
995-
"raw": "{{host}}/api/rentallistings/408",
995+
"raw": "{{host}}/api/rentallistings/612",
996996
"host": [
997997
"{{host}}"
998998
],
999999
"path": [
10001000
"api",
10011001
"rentallistings",
1002-
"408"
1002+
"612"
10031003
]
10041004
}
10051005
},
@@ -1361,14 +1361,20 @@
13611361
"formdata": []
13621362
},
13631363
"url": {
1364-
"raw": "{{host}}/api/bizlicenses/uploadhistory",
1364+
"raw": "{{host}}/api/bizlicenses/uploadhistory?orgId=256",
13651365
"host": [
13661366
"{{host}}"
13671367
],
13681368
"path": [
13691369
"api",
13701370
"bizlicenses",
13711371
"uploadhistory"
1372+
],
1373+
"query": [
1374+
{
1375+
"key": "orgId",
1376+
"value": "256"
1377+
}
13721378
]
13731379
}
13741380
},

server/StrDss.Data/Entities/DssDbContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
956956
entity.Property(e => e.BcRegistryNo)
957957
.HasMaxLength(50)
958958
.HasColumnName("bc_registry_no");
959+
entity.Property(e => e.BusinessLicenceId).HasColumnName("business_licence_id");
959960
entity.Property(e => e.BusinessLicenceNo)
960961
.HasMaxLength(320)
961962
.HasColumnName("business_licence_no");

server/StrDss.Data/Entities/DssRentalListingVw.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,6 @@ public partial class DssRentalListingVw
8888
public string? LastActionNm { get; set; }
8989

9090
public DateTime? LastActionDtm { get; set; }
91+
92+
public long? BusinessLicenceId { get; set; }
9193
}

server/StrDss.Data/Mappings/EntityToModelProfile.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public EntityToModelProfile()
4343
CreateMap<DssRentalListingVw, RentalListingExportDto>();
4444
CreateMap<DssRentalListingExtract, RentalListingExtractDto>()
4545
.ForMember(o => o.UpdDtm, opt => opt.MapFrom(i => DateUtils.ConvertUtcToPacificTime(i.UpdDtm)));
46+
47+
CreateMap<DssBusinessLicenceStatusType, LicenseStatus>();
48+
49+
CreateMap<DssBusinessLicence, BizLicenseDto>()
50+
.ForMember(o => o.UpdDtm, opt => opt.MapFrom(i => DateUtils.ConvertUtcToPacificTime(i.UpdDtm)));
4651
}
4752
}
4853
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using AutoMapper;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.Extensions.Logging;
4+
using StrDss.Common;
5+
using StrDss.Data.Entities;
6+
using StrDss.Model;
7+
8+
namespace StrDss.Data.Repositories
9+
{
10+
public interface IBizLicenseRepository
11+
{
12+
Task<BizLicenseDto?> GetBizLicense(long businessLicenceId);
13+
}
14+
15+
public class BizLicenseRepository : RepositoryBase<DssBusinessLicence>, IBizLicenseRepository
16+
{
17+
public BizLicenseRepository(DssDbContext dbContext, IMapper mapper, ICurrentUser currentUser, ILogger<StrDssLogger> logger)
18+
: base(dbContext, mapper, currentUser, logger)
19+
{
20+
}
21+
22+
public async Task<BizLicenseDto?> GetBizLicense(long businessLicenceId)
23+
{
24+
return _mapper.Map<BizLicenseDto>(await _dbSet.AsNoTracking().FirstOrDefaultAsync(x => x.BusinessLicenceId == businessLicenceId));
25+
}
26+
}
27+
}

server/StrDss.Data/Repositories/RentalListingRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ var extraSort
218218

219219
listing.AddressChangeHistory = await GetAddressChangeHistoryAsync(rentalListingId);
220220

221+
listing.BizLicenseDto = _mapper.Map<BizLicenseDto>(await _dbContext.DssBusinessLicences.AsNoTracking().FirstOrDefaultAsync(x => x.BusinessLicenceId == listing.BusinessLicenceId));
222+
221223
return listing;
222224
}
223225

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace StrDss.Model
2+
{
3+
public class BizLicenseDto
4+
{
5+
public long BusinessLicenceId { get; set; }
6+
public string BusinessLicenceNo { get; set; } = null!;
7+
public DateOnly ExpiryDt { get; set; }
8+
public string? PhysicalRentalAddressTxt { get; set; }
9+
public string? LicenceTypeTxt { get; set; }
10+
public string? RestrictionTxt { get; set; }
11+
public string? BusinessNm { get; set; }
12+
public string? MailingStreetAddressTxt { get; set; }
13+
public string? MailingCityNm { get; set; }
14+
public string? MailingProvinceCd { get; set; }
15+
public string? MailingPostalCd { get; set; }
16+
public string? BusinessOwnerNm { get; set; }
17+
public string? BusinessOwnerPhoneNo { get; set; }
18+
public string? BusinessOwnerEmailAddressDsc { get; set; }
19+
public string? BusinessOperatorNm { get; set; }
20+
public string? BusinessOperatorPhoneNo { get; set; }
21+
public string? BusinessOperatorEmailAddressDsc { get; set; }
22+
public string? InfractionTxt { get; set; }
23+
public DateOnly? InfractionDt { get; set; }
24+
public string? PropertyZoneTxt { get; set; }
25+
public short? AvailableBedroomsQty { get; set; }
26+
public short? MaxGuestsAllowedQty { get; set; }
27+
public bool? IsPrincipalResidence { get; set; }
28+
public bool? IsOwnerLivingOnsite { get; set; }
29+
public bool? IsOwnerPropertyTenant { get; set; }
30+
public string? PropertyFolioNo { get; set; }
31+
public string? PropertyParcelIdentifierNo { get; set; }
32+
public string? PropertyLegalDescriptionTxt { get; set; }
33+
public string LicenceStatusType { get; set; } = null!;
34+
public long ProvidingOrganizationId { get; set; }
35+
public long? AffectedByPhysicalAddressId { get; set; }
36+
public DateTime UpdDtm { get; set; }
37+
public Guid? UpdUserGuid { get; set; }
38+
public virtual LicenseStatus LicenseStatus { get; set; } = null!;
39+
}
40+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace StrDss.Model
2+
{
3+
public class LicenseStatus
4+
{
5+
public string LicenceStatusType { get; set; } = null!;
6+
7+
public string LicenceStatusTypeNm { get; set; } = null!;
8+
9+
public short LicenceStatusSortNo { get; set; }
10+
}
11+
}

server/StrDss.Model/RentalReportDtos/RentalListingViewDto.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace StrDss.Model.RentalReportDtos
1+
using Microsoft.VisualBasic;
2+
3+
namespace StrDss.Model.RentalReportDtos
24
{
35
public class RentalListingViewDto
46
{
@@ -77,15 +79,16 @@ public class RentalListingViewDto
7779
public string? BcRegistryNo { get; set; }
7880

7981
public string? LastActionNm { get; set; }
80-
82+
public long? BusinessLicenceId { get; set; }
8183
public DateTime? LastActionDtm { get; set; }
8284
public bool HasAtLeastOneValidHostEmail { get; set; }
8385
public List<HostInfo> HostsInfo { get; set; } = new List<HostInfo>();
84-
86+
public BizLicenseDto? BizLicenseDto { get; set; }
8587
public virtual ICollection<RentalListingContactDto> Hosts { get; set; } = new List<RentalListingContactDto>();
8688
public virtual ICollection<ListingHistoryDto> ListingHistory { get; set; } = new List<ListingHistoryDto>();
8789
public virtual ICollection<ActionHistoryDto> ActionHistory { get; set; } = new List<ActionHistoryDto>();
8890
public virtual ICollection<AddressChangeHistoryDto> AddressChangeHistory { get; set; } = new List<AddressChangeHistoryDto>();
91+
8992
}
9093

9194
public class HostInfo

0 commit comments

Comments
 (0)