Skip to content

Commit

Permalink
[SPDBT-3394] Fix cm update and block null value (#1913)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- fix cm update and block null value
  • Loading branch information
peggy-quartech authored Nov 29, 2024
1 parent b727528 commit ef33ece
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/Spd.Manager.Licence/ControllingMemberCrcAppContract.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MediatR;
using MediatR;
using Spd.Manager.Shared;

namespace Spd.Manager.Licence;
Expand Down Expand Up @@ -97,6 +97,7 @@ public record ControllingMemberCrcAppUpdateRequest
public bool? HasNewCriminalRecordCharge { get; set; }
public bool? HasNewMentalHealthCondition { get; set; }
public bool? AgreeToCompleteAndAccurate { get; set; }
public DateOnly? DateOfBirth { get; set; }
public IEnumerable<Guid>? DocumentKeyCodes { get; set; }
public IEnumerable<Guid>? PreviousDocumentIds { get; set; }
public IEnumerable<DocumentExpiredInfo> DocumentExpiredInfos { get; set; } = Enumerable.Empty<DocumentExpiredInfo>();
Expand Down
20 changes: 11 additions & 9 deletions src/Spd.Manager.Licence/ControllingMemberCrcAppManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AutoMapper;
using AutoMapper;
using MediatR;
using Spd.Resource.Repository;
using Spd.Resource.Repository.BizContact;
Expand Down Expand Up @@ -74,23 +74,25 @@ await ValidateInviteIdAsync(cmd.ControllingMemberCrcAppRequest.InviteId,
ct);
ControllingMemberCrcAppUpdateRequest request = cmd.ControllingMemberCrcAppRequest;

var existingFiles = await GetExistingFileInfo(cmd.ControllingMemberCrcAppRequest.ControllingMemberAppId, cmd.ControllingMemberCrcAppRequest.PreviousDocumentIds, ct);
//check validation
ValidateFilesForUpdateAppAsync(cmd.ControllingMemberCrcAppRequest,
cmd.LicAppFileInfos.ToList(),
existingFiles,
ct);
//no need to get existing files
//var existingFiles = await GetExistingFileInfo(cmd.ControllingMemberCrcAppRequest.ControllingMemberAppId, cmd.ControllingMemberCrcAppRequest.PreviousDocumentIds, ct);
////check validation
//ValidateFilesForUpdateAppAsync(cmd.ControllingMemberCrcAppRequest,
// cmd.LicAppFileInfos.ToList(),
// existingFiles,
// ct);
ContactResp? contact = await _contactRepository.GetAsync((Guid)request.ApplicantId, ct);
if (contact == null)
throw new ApiException(HttpStatusCode.BadRequest, "Applicant info not found");

BizContactResp? bizContact = await _bizContactRepository.GetBizContactAsync(request.BizContactId, ct);
if (bizContact == null)
throw new ApiException(HttpStatusCode.BadRequest, "Business Contact not found");

LicenceListResp licences = await _licenceRepository.QueryAsync(new LicenceQry()
{
AccountId = bizContact.BizId,
Type = ServiceTypeEnum.SECURITY_BUSINESS_LICENCE_CONTROLLING_MEMBER_CRC
Type = ServiceTypeEnum.SecurityBusinessLicence
}, ct);

LicenceResp? bizLicence = licences?.Items?.SingleOrDefault();
Expand Down Expand Up @@ -118,7 +120,7 @@ await UploadNewDocsAsync(request.DocumentExpiredInfos,
await DeactiveInviteAsync(cmd.ControllingMemberCrcAppRequest.InviteId, ct);
return new ControllingMemberCrcAppCommandResponse()
{
ControllingMemberAppId = (Guid)cmd.ControllingMemberCrcAppRequest.ControllingMemberAppId
ControllingMemberAppId = cmd.ControllingMemberCrcAppRequest.ControllingMemberAppId ?? Guid.Empty //update cm does not have application Id
};
}

Expand Down
1 change: 1 addition & 0 deletions src/Spd.Manager.Licence/Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public Mappings()
.ForMember(d => d.FirstName, opt => opt.MapFrom(s => s.GivenName))
.ForMember(d => d.LastName, opt => opt.MapFrom(s => s.Surname))
.ForMember(d => d.Gender, opt => opt.MapFrom(s => s.GenderCode))
.ForMember(d => d.BirthDate, opt => opt.MapFrom(s => s.DateOfBirth))
.ForPath(d => d.ResidentialAddress.AddressLine1, opt => opt.MapFrom(s => s.ResidentialAddress.AddressLine1))
.ForPath(d => d.ResidentialAddress.AddressLine2, opt => opt.MapFrom(s => s.ResidentialAddress.AddressLine2))
.ForPath(d => d.ResidentialAddress.Province, opt => opt.MapFrom(s => s.ResidentialAddress.Province))
Expand Down
2 changes: 1 addition & 1 deletion src/Spd.Utilities.Dynamics/ODataClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void OnClientCreated(ClientCreatedArgs args)
client.Configurations.RequestPipeline.OnEntryStarting((arg) =>
{
// do not send reference properties and null values to Dynamics
arg.Entry.Properties = arg.Entry.Properties.Cast<ODataProperty>().Where((prop) => !prop.Name.StartsWith('_') /*&& prop.Value != null*/);
arg.Entry.Properties = arg.Entry.Properties.Cast<ODataProperty>().Where((prop) => !prop.Name.StartsWith('_') && prop.Value != null);
});
client.BuildingRequest += Client_BuildingRequest;
client.SendingRequest2 += Client_SendingRequest2;
Expand Down

0 comments on commit ef33ece

Please sign in to comment.