Skip to content

Commit

Permalink
add issued category to licence response (#1337)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- add issued category to licence response
  • Loading branch information
esdd1995 authored Aug 24, 2024
2 parents fb99fac + d7a54a2 commit 21f6ab0
Show file tree
Hide file tree
Showing 7 changed files with 12,419 additions and 2,528 deletions.
3 changes: 3 additions & 0 deletions src/Spd.Manager.Licence/LicenceContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public record LicenceBasicResponse
public Guid? LicenceHolderId { get; set; }
public string? NameOnCard { get; set; }
public LicenceStatusCode LicenceStatusCode { get; set; }

//issued categories
public IEnumerable<WorkerCategoryTypeCode> CategoryCodes { get; set; } = Array.Empty<WorkerCategoryTypeCode>();
};

public record LicenceResponse : LicenceBasicResponse
Expand Down
3 changes: 3 additions & 0 deletions src/Spd.Resource.Repository/Licence/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public record Licence
public string? LicenceHolderMiddleName1 { get; set; }
public LicenceStatusEnum LicenceStatusCode { get; set; }
public string? NameOnCard { get; set; }

//issued categories
public IEnumerable<WorkerCategoryTypeEnum> CategoryCodes { get; set; } = Array.Empty<WorkerCategoryTypeEnum>();
}

public record PermitLicence : Licence
Expand Down
2 changes: 2 additions & 0 deletions src/Spd.Resource.Repository/Licence/LicenceRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public LicenceRepository(IDynamicsContextFactory ctx,
.Expand(i => i.spd_LicenceHolder_contact)
.Expand(i => i.spd_LicenceHolder_account)
.Expand(i => i.spd_CaseId)
.Expand(i => i.spd_spd_licence_spd_caselicencecategory_licenceid)
.Where(l => l.spd_licenceid == licenceId)
.FirstOrDefaultAsync(ct);
}
Expand All @@ -47,6 +48,7 @@ public async Task<LicenceListResp> QueryAsync(LicenceQry qry, CancellationToken
}

IQueryable<spd_licence> lics = _context.spd_licences
.Expand(i => i.spd_spd_licence_spd_caselicencecategory_licenceid)
.Expand(i => i.spd_LicenceHolder_contact)
.Expand(i => i.spd_LicenceHolder_account)
.Expand(i => i.spd_CaseId);
Expand Down
11 changes: 10 additions & 1 deletion src/Spd.Resource.Repository/Licence/Mappings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AutoMapper;
using Microsoft.Dynamics.CRM;
using Spd.Resource.Repository.PersonLicApplication;
using Spd.Utilities.Dynamics;

namespace Spd.Resource.Repository.Licence
Expand Down Expand Up @@ -31,7 +32,8 @@ public Mappings()
.ForMember(d => d.Rationale, opt => opt.MapFrom(s => s.spd_rationale))
.ForMember(d => d.PhotoDocumentUrlId, opt => opt.MapFrom(s => s._spd_photographid_value))
.ForMember(d => d.IsTemporary, opt => opt.MapFrom(s => SharedMappingFuncs.GetBool(s.spd_temporarylicence)))
.ForMember(d => d.PermitPurposeEnums, opt => opt.MapFrom(s => SharedMappingFuncs.GetPermitPurposeEnums(s.spd_permitpurpose)));
.ForMember(d => d.PermitPurposeEnums, opt => opt.MapFrom(s => SharedMappingFuncs.GetPermitPurposeEnums(s.spd_permitpurpose)))
.ForMember(d => d.CategoryCodes, opt => opt.MapFrom(s => GetCategoryCodes(s.spd_spd_licence_spd_caselicencecategory_licenceid.ToList())));

_ = CreateMap<spd_licence, Addr>()
.ForMember(d => d.AddressLine1, opt => opt.MapFrom(s => s.spd_employeraddress1))
Expand Down Expand Up @@ -65,5 +67,12 @@ public Mappings()
if (optionset == null) return null;
return Enum.Parse<LicenceStatusEnum>(Enum.GetName(typeof(LicenceStatusOptionSet), optionset));
}

internal static IEnumerable<WorkerCategoryTypeEnum> GetCategoryCodes(List<spd_caselicencecategory> categories)
{
return categories
.Where(c => c.spd_accepted == (int)YesNoOptionSet.Yes)
.Select(c => Enum.Parse<WorkerCategoryTypeEnum>(DynamicsContextLookupHelpers.LookupLicenceCategoryKey(c._spd_licencecategoryid_value)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"MakeTypesInternal": false,
"O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ugT4ntL-7uRtRCz8lmhDX1ED7sGYe_yCxtmJ0AbtNBV0dlTe_6M60rHarWQrlox2aguhAMJjrT8Q",
"IncludeWebProxy": false,
"WebProxyHost": null,
"IncludeWebProxyNetworkCredentials": false,
Expand Down
Loading

0 comments on commit 21f6ab0

Please sign in to comment.