diff --git a/src/Spd.Manager.Printing/Documents/TransformationStrategies/BizLicencePrintingTransformStrategy.cs b/src/Spd.Manager.Printing/Documents/TransformationStrategies/BizLicencePrintingTransformStrategy.cs index af9767b51..54172b440 100644 --- a/src/Spd.Manager.Printing/Documents/TransformationStrategies/BizLicencePrintingTransformStrategy.cs +++ b/src/Spd.Manager.Printing/Documents/TransformationStrategies/BizLicencePrintingTransformStrategy.cs @@ -42,10 +42,7 @@ protected override async Task CreateDocument(BizLicenceP mapper.Map(biz, bizLicJson); //conditions - IncidentListResp resp = await incidentRepository.QueryAsync( - new IncidentQry() { ApplicationId = lic.LicenceAppId, IncludeInactive = true }, - cancellationToken); - bizLicJson.Conditions = resp.Items.First().Conditions.Select(c => c.Name); + bizLicJson.Conditions = lic.Conditions.Select(c => c.Name); return bizLicJson; } diff --git a/src/Spd.Manager.Printing/Documents/TransformationStrategies/PersonalLicencePreviewTransformStrategy.cs b/src/Spd.Manager.Printing/Documents/TransformationStrategies/PersonalLicencePreviewTransformStrategy.cs index ff3ef04d4..adc480da1 100644 --- a/src/Spd.Manager.Printing/Documents/TransformationStrategies/PersonalLicencePreviewTransformStrategy.cs +++ b/src/Spd.Manager.Printing/Documents/TransformationStrategies/PersonalLicencePreviewTransformStrategy.cs @@ -51,10 +51,7 @@ protected override async Task CreateDocument(PersonalLicence preview.SPD_CARD.TemporaryLicence = lic.IsTemporary ?? false; //conditions - IncidentListResp resp = await incidentRepository.QueryAsync( - new IncidentQry() { ApplicationId = lic.LicenceAppId, IncludeInactive = true }, - cancellationToken); - preview.Conditions = resp.Items.First().Conditions.Select(c => c.Name); + preview.Conditions = lic.Conditions.Select(c => c.Name); return preview; } diff --git a/src/Spd.Resource.Repository/Licence/Contract.cs b/src/Spd.Resource.Repository/Licence/Contract.cs index 22db5a87a..43a5dd499 100644 --- a/src/Spd.Resource.Repository/Licence/Contract.cs +++ b/src/Spd.Resource.Repository/Licence/Contract.cs @@ -55,6 +55,8 @@ public record LicenceResp() : PermitLicence //sole proprietor public Guid? SoleProprietorOrgId { get; set; } + + public IEnumerable Conditions { get; set; } = Enumerable.Empty(); } public record Licence @@ -88,6 +90,12 @@ public record PermitLicence : Licence public IEnumerable? PermitPurposeEnums { get; set; } } + public record Condition + { + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + } + public enum LicenceStatusEnum { Active, diff --git a/src/Spd.Resource.Repository/Licence/LicenceRepository.cs b/src/Spd.Resource.Repository/Licence/LicenceRepository.cs index c319bcdb0..7cc36a962 100644 --- a/src/Spd.Resource.Repository/Licence/LicenceRepository.cs +++ b/src/Spd.Resource.Repository/Licence/LicenceRepository.cs @@ -24,6 +24,7 @@ public LicenceRepository(IDynamicsContextFactory ctx, licence = await _context.spd_licences .Expand(i => i.spd_LicenceHolder_contact) .Expand(i => i.spd_LicenceHolder_account) + .Expand(i => i.spd_spd_licence_spd_licencecondition) .Expand(i => i.spd_CaseId) .Expand(i => i.spd_SoleProprietorId) .Expand(i => i.spd_spd_licence_spd_caselicencecategory_licenceid) @@ -45,6 +46,7 @@ public async Task QueryAsync(LicenceQry qry, CancellationToken { IQueryable lics = _context.spd_licences .Expand(i => i.spd_spd_licence_spd_caselicencecategory_licenceid) + .Expand(i => i.spd_spd_licence_spd_licencecondition) .Expand(i => i.spd_LicenceHolder_contact) .Expand(i => i.spd_LicenceHolder_account) .Expand(i => i.spd_CaseId); diff --git a/src/Spd.Resource.Repository/Licence/Mappings.cs b/src/Spd.Resource.Repository/Licence/Mappings.cs index 72015e0a8..f0c8e41c7 100644 --- a/src/Spd.Resource.Repository/Licence/Mappings.cs +++ b/src/Spd.Resource.Repository/Licence/Mappings.cs @@ -45,8 +45,13 @@ public Mappings() .ForMember(d => d.IsDogsPurposeDetectionExplosives, opt => opt.MapFrom(s => SharedMappingFuncs.GetDogReasonFlag(s.spd_requestdogsreasons, RequestDogPurposeOptionSet.DetectionExplosives))) .ForMember(d => d.CarryAndUseRestraints, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_requestrestraints))) .ForMember(d => d.UseDogs, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_requestdogs))) + .ForMember(d => d.Conditions, opt => opt.MapFrom(s => s.spd_spd_licence_spd_licencecondition)) ; + _ = CreateMap() + .ForMember(d => d.Id, opt => opt.MapFrom(s => s.spd_licenceconditionid)) + .ForMember(d => d.Name, opt => opt.MapFrom(s => s.spd_conditionname)); + _ = CreateMap() .ForMember(d => d.AddressLine1, opt => opt.MapFrom(s => s.spd_employeraddress1)) .ForMember(d => d.AddressLine2, opt => opt.MapFrom(s => s.spd_employeraddress2))