Skip to content

Commit 2897028

Browse files
remove cm from biz app payload (#1376)
# Description This PR includes the following proposed change(s): - we need to remove controlling member from biz lic app payload as we separately deal with members
1 parent 2a7e79d commit 2897028

File tree

6 files changed

+0
-142
lines changed

6 files changed

+0
-142
lines changed

src/Spd.Manager.Licence.UnitTest/BizLicAppValidationTest.cs

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -194,56 +194,6 @@ public void PrivateInvestigatorSwlInfo_WhenHasEmptyFields_ShouldThrowException()
194194
result.ShouldHaveValidationErrorFor(r => r.PrivateInvestigatorSwlInfo);
195195
}
196196

197-
[Fact]
198-
public void ControllingMembers_WhenHasEmptyFields_ShouldThrowException()
199-
{
200-
BizLicAppUpsertRequestValidator validator = new BizLicAppUpsertRequestValidator();
201-
202-
var model = GenerateValidRequest<BizLicAppUpsertRequest>();
203-
204-
List<SwlContactInfo> swlControllingMembers = new() { new SwlContactInfo() };
205-
List<NonSwlContactInfo> nonSwlControllingMembers = new() { new NonSwlContactInfo() };
206-
List<SwlContactInfo> employees = new() { new SwlContactInfo() };
207-
Members members = new()
208-
{
209-
SwlControllingMembers = swlControllingMembers,
210-
NonSwlControllingMembers = nonSwlControllingMembers,
211-
Employees = employees
212-
};
213-
model.Members = members;
214-
215-
var result = validator.TestValidate(model);
216-
result.ShouldHaveValidationErrorFor(r => r.Members.SwlControllingMembers);
217-
result.ShouldHaveValidationErrorFor(r => r.Members.NonSwlControllingMembers);
218-
result.ShouldHaveValidationErrorFor(r => r.Members.Employees);
219-
}
220-
221-
[Fact]
222-
public void ControllingMembers_WhenExceedsMaxAllowed_ShouldThrowException()
223-
{
224-
BizLicAppUpsertRequestValidator validator = new BizLicAppUpsertRequestValidator();
225-
226-
var model = GenerateValidRequest<BizLicAppUpsertRequest>();
227-
List<SwlContactInfo> swlControllingMembers = fixture.CreateMany<SwlContactInfo>(10).ToList();
228-
List<NonSwlContactInfo> nonSwlControllingMembers = fixture.Build<NonSwlContactInfo>()
229-
.With(c => c.EmailAddress, "test@test.com")
230-
.CreateMany(11)
231-
.ToList();
232-
List<SwlContactInfo> employees = fixture.CreateMany<SwlContactInfo>(21).ToList();
233-
234-
Members members = new()
235-
{
236-
SwlControllingMembers = swlControllingMembers,
237-
NonSwlControllingMembers = nonSwlControllingMembers,
238-
Employees = employees
239-
};
240-
model.Members = members;
241-
242-
var result = validator.TestValidate(model);
243-
result.ShouldHaveValidationErrorFor(r => r.Members);
244-
result.ShouldHaveValidationErrorFor(r => r.Members.Employees);
245-
}
246-
247197
private T GenerateValidRequest<T>()
248198
{
249199
object model;
@@ -266,13 +216,6 @@ private T GenerateValidRequest<T>()
266216
List<NonSwlContactInfo> nonSwlControllingMembers = new() { new NonSwlContactInfo() { Surname = "test", EmailAddress = "test@test.com" } };
267217
List<SwlContactInfo> employees = new() { new SwlContactInfo() { LicenceId = Guid.NewGuid() } };
268218

269-
Members members = new()
270-
{
271-
SwlControllingMembers = swlControllingMembers,
272-
NonSwlControllingMembers = nonSwlControllingMembers,
273-
Employees = employees
274-
};
275-
276219
if (typeof(T).Name == "BizLicAppUpsertRequest")
277220
{
278221
// Documents
@@ -297,7 +240,6 @@ private T GenerateValidRequest<T>()
297240
.With(r => r.DocumentInfos, documentInfos)
298241
.With(r => r.CategoryCodes, categories)
299242
.With(r => r.ApplicantContactInfo, applicantContactInfo)
300-
.With(r => r.Members, members)
301243
.Create();
302244
}
303245
else
@@ -310,7 +252,6 @@ private T GenerateValidRequest<T>()
310252
.With(r => r.NoBranding, false)
311253
.With(r => r.CategoryCodes, categories)
312254
.With(r => r.ApplicantContactInfo, applicantContactInfo)
313-
.With(r => r.Members, members)
314255
.Create();
315256
}
316257

src/Spd.Manager.Licence.UnitTest/BizLicenceAppManagerTest.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ public async void Handle_BizLicAppUpsertCommand_WithoutLicAppId_Return_BizLicApp
156156
WorkerLicenceTypeCode = WorkerLicenceTypeCode.SecurityWorkerLicence,
157157
BizId = bizId,
158158
DocumentInfos = new List<Document>() { workPermit },
159-
Members = members
160159
};
161160

162161
//Act
@@ -254,20 +253,12 @@ public async void Handle_BizLicAppSubmitCommand_WithoutLicAppId_Return_BizLicApp
254253
.With(d => d.LicenceDocumentTypeCode, LicenceDocumentTypeCode.WorkPermit)
255254
.Create();
256255

257-
Members members = new()
258-
{
259-
SwlControllingMembers = new List<SwlContactInfo>(),
260-
NonSwlControllingMembers = new List<NonSwlContactInfo>(),
261-
Employees = new List<SwlContactInfo>()
262-
};
263-
264256
BizLicAppUpsertRequest request = new()
265257
{
266258
LicenceAppId = null,
267259
WorkerLicenceTypeCode = WorkerLicenceTypeCode.SecurityWorkerLicence,
268260
BizId = bizId,
269261
DocumentInfos = new List<Document>() { workPermit },
270-
Members = members
271262
};
272263

273264
//Act

src/Spd.Manager.Licence/BizLicAppBaseValidation.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using FluentValidation;
2-
using Microsoft.IdentityModel.Tokens;
32
using System.Text.RegularExpressions;
43

54
namespace Spd.Manager.Licence;
@@ -59,34 +58,5 @@ public BizLicAppBaseValidator()
5958
r.BizTypeCode != BizTypeCode.NonRegisteredSoleProprietor &&
6059
r.BizTypeCode != BizTypeCode.RegisteredSoleProprietor)
6160
.WithMessage("Missing private investigator information.");
62-
63-
// Controlling members
64-
RuleFor(r => r.Members.SwlControllingMembers)
65-
.ForEach(r => r
66-
.Must(m => m.LicenceId != null && m.LicenceId != Guid.Empty))
67-
.When(r => r.Members != null && r.Members.SwlControllingMembers != null)
68-
.WithMessage("Missing licence Id in Controlling members (SWL)");
69-
70-
RuleFor(r => r.Members.NonSwlControllingMembers)
71-
.ForEach(r => r
72-
.Must(m => m.Surname.IsNullOrEmpty() != true)
73-
.Must(m => m.EmailAddress != null ? emailRegex.IsMatch(m.EmailAddress) : true))
74-
.WithMessage("Missing surname in Controlling members (not SWL)")
75-
.When(r => r.Members != null && r.Members.NonSwlControllingMembers != null);
76-
77-
RuleFor(r => r.Members)
78-
.Must(r => r.SwlControllingMembers.Count() + r.NonSwlControllingMembers.Count() <= 20)
79-
.When(r => r.Members != null && r.Members.SwlControllingMembers != null && r.Members.NonSwlControllingMembers != null);
80-
81-
// Employees
82-
RuleFor(r => r.Members.Employees)
83-
.ForEach(r => r
84-
.Must(m => m.LicenceId != null && m.LicenceId != Guid.Empty))
85-
.When(r => r.Members != null && r.Members.Employees != null)
86-
.WithMessage("Missing information in employees");
87-
RuleFor(r => r.Members.Employees)
88-
.Must(r => r.Count() <= 20)
89-
.When(r => r.Members != null && r.Members.Employees != null)
90-
.WithMessage("No more than 20 employees are allowed");
9161
}
9262
}

src/Spd.Manager.Licence/BizLicAppContract.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public abstract record BizLicenceApp : LicenceAppBase
8686

8787
//non sole proprietor properties
8888
public ContactInfo? ApplicantContactInfo { get; set; }
89-
public Members? Members { get; set; }
9089
public IEnumerable<WorkerCategoryTypeCode> CategoryCodes { get; set; } = Array.Empty<WorkerCategoryTypeCode>(); //todo: Matrix
9190
public PrivateInvestigatorSwlContactInfo? PrivateInvestigatorSwlInfo { get; set; } //it does not put into spd_businesscontact, so no id for it
9291
public bool? AgreeToCompleteAndAccurate { get; set; }

src/Spd.Manager.Licence/BizLicAppManager.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ public async Task<BizLicAppCommandResponse> Handle(BizLicAppUpsertCommand cmd, C
103103
if (cmd.BizLicAppUpsertRequest.LicenceAppId == null)
104104
cmd.BizLicAppUpsertRequest.LicenceAppId = response.LicenceAppId;
105105

106-
if (cmd.BizLicAppUpsertRequest.Members != null && cmd.BizLicAppUpsertRequest.BizId != null)
107-
await UpdateMembersAsync(cmd.BizLicAppUpsertRequest.Members,
108-
cmd.BizLicAppUpsertRequest.BizId,
109-
cancellationToken);
110-
111106
if (cmd.BizLicAppUpsertRequest.DocumentInfos != null && cmd.BizLicAppUpsertRequest.DocumentInfos.Any())
112107
await UpdateDocumentsAsync(
113108
(Guid)cmd.BizLicAppUpsertRequest.LicenceAppId,
@@ -151,12 +146,6 @@ public async Task<BizLicAppCommandResponse> Handle(BizLicAppReplaceCommand cmd,
151146

152147
decimal cost = await CommitApplicationAsync(request, response.LicenceAppId, cancellationToken);
153148

154-
// Update members
155-
if (cmd.LicenceRequest.Members != null)
156-
await UpdateMembersAsync(cmd.LicenceRequest.Members,
157-
(Guid)originalLic.BizId,
158-
cancellationToken);
159-
160149
return new BizLicAppCommandResponse { LicenceAppId = response.LicenceAppId, Cost = cost };
161150
}
162151

@@ -197,12 +186,6 @@ await ValidateFilesForRenewUpdateAppAsync(cmd.LicenceRequest,
197186
createApp.UploadedDocumentEnums = GetUploadedDocumentEnums(cmd.LicAppFileInfos, existingFiles);
198187
BizLicApplicationCmdResp response = await _bizLicApplicationRepository.CreateBizLicApplicationAsync(createApp, cancellationToken);
199188

200-
// Update members
201-
if (cmd.LicenceRequest.Members != null)
202-
await UpdateMembersAsync(cmd.LicenceRequest.Members,
203-
(Guid)originalBizLic.BizId,
204-
cancellationToken);
205-
206189
// Upload new files
207190
await UploadNewDocsAsync(null,
208191
cmd.LicAppFileInfos,
@@ -290,12 +273,6 @@ await _documentRepository.ManageAsync(
290273
cost = await CommitApplicationAsync(request, response.LicenceAppId, cancellationToken);
291274
}
292275

293-
// Update members
294-
if (cmd.LicenceRequest.Members != null)
295-
await UpdateMembersAsync(cmd.LicenceRequest.Members,
296-
(Guid)originalLicApp.BizId,
297-
cancellationToken);
298-
299276
return new BizLicAppCommandResponse { LicenceAppId = response?.LicenceAppId ?? originalLicApp.LicenceAppId, Cost = cost };
300277
}
301278

@@ -544,24 +521,6 @@ private async Task<CreateBizLicApplicationCmd> SetBizManagerInfo(
544521
return createApp;
545522
}
546523

547-
548-
//todo: if fe can make seperate call to members and application, then we can give all members related info to BizMemberManager, then this function
549-
//can be removed.
550-
private async Task<Unit> UpdateMembersAsync(Members members, Guid bizId, CancellationToken ct)
551-
{
552-
List<BizContactResp> contacts = _mapper.Map<List<BizContactResp>>(members.NonSwlControllingMembers);
553-
contacts.AddRange(_mapper.Map<IList<BizContactResp>>(members.SwlControllingMembers));
554-
IList<BizContactResp> employees = _mapper.Map<IList<BizContactResp>>(members.Employees);
555-
foreach (var e in employees)
556-
{
557-
e.BizContactRoleCode = BizContactRoleEnum.Employee;
558-
}
559-
contacts.AddRange(employees);
560-
BizContactUpsertCmd upsertCmd = new(bizId, contacts);
561-
await _bizContactRepository.ManageBizContactsAsync(upsertCmd, ct);
562-
return default;
563-
}
564-
565524
private sealed record ChangeSpec
566525
{
567526
public bool CategoriesChanged { get; set; }

src/Spd.Presentation.Licensing/Controllers/BizLicensingController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public BizLicensingController(IPrincipal currentUser,
4949
public async Task<BizLicAppResponse> GetBizLicenceApplication([FromRoute][Required] Guid licenceAppId, CancellationToken ct)
5050
{
5151
BizLicAppResponse response = await _mediator.Send(new GetBizLicAppQuery(licenceAppId));
52-
if (response.BizId != null)
53-
response.Members = await _mediator.Send(new GetBizMembersQuery((Guid)response.BizId, null), ct);
5452
return response;
5553
}
5654

0 commit comments

Comments
 (0)