Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPDBT-3472] PI showing as employee #2064

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Spd.Manager.Licence/BizMemberManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public async Task<Members> Handle(GetBizMembersQuery qry, CancellationToken ct)
.Where(c => c.BizContactRoleCode == BizContactRoleEnum.ControllingMember)
.Select(c => _mapper.Map<NonSwlContactInfo>(c));
members.Employees = bizMembers.Where(c => c.ContactId != null && c.LicenceId != null)
.Where(c => c.BizContactRoleCode == BizContactRoleEnum.Employee)
.Where(c => c.BizContactRoleCode == BizContactRoleEnum.Employee && !c.PositionCodes.Any(c => c == PositionEnum.PrivateInvestigatorManager))
.Select(c => _mapper.Map<SwlContactInfo>(c));
return members;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using AutoMapper;
using Microsoft.Dynamics.CRM;
using Microsoft.Extensions.Logging;
using Spd.Resource.Repository.PersonLicApplication;
using Spd.Utilities.Dynamics;
using Spd.Utilities.Shared.Exceptions;
using System.Net;
Expand Down Expand Up @@ -41,6 +40,7 @@ public BizContactRepository(IDynamicsContextFactory ctx,
public async Task<IEnumerable<BizContactResp>> QueryBizContactsAsync(BizContactQry qry, CancellationToken ct)
{
IQueryable<spd_businesscontact> bizContacts = _context.spd_businesscontacts
.Expand(c => c.spd_position_spd_businesscontact)
.Expand(c => c.spd_businesscontact_spd_application)
.Expand(c => c.spd_businesscontact_spd_portalinvitation);

Expand Down
2 changes: 2 additions & 0 deletions src/Spd.Resource.Repository/BizContact/Contract.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Spd.Resource.Repository.Application;
using Spd.Resource.Repository.BizLicApplication;

namespace Spd.Resource.Repository.BizContact
{
Expand Down Expand Up @@ -39,6 +40,7 @@ public record BizContact
public Guid? ContactId { get; set; }
public Guid? LicenceId { get; set; }
public BizContactRoleEnum BizContactRoleCode { get; set; } = BizContactRoleEnum.ControllingMember;
public IEnumerable<PositionEnum> PositionCodes { get; set; } = Enumerable.Empty<PositionEnum>();
public Guid BizId { get; set; }
}

Expand Down
7 changes: 7 additions & 0 deletions src/Spd.Resource.Repository/BizContact/Mappings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AutoMapper;
using Microsoft.Dynamics.CRM;
using Spd.Resource.Repository.Application;
using Spd.Resource.Repository.BizLicApplication;
using Spd.Utilities.Dynamics;

namespace Spd.Resource.Repository.BizContact
Expand All @@ -23,6 +24,7 @@ public Mappings()
.IncludeBase<spd_businesscontact, BizContact>()
.ForMember(d => d.BizContactId, opt => opt.MapFrom(s => s.spd_businesscontactid))
.ForMember(d => d.BizContactRoleCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<BizContactRoleOptionSet, BizContactRoleEnum>(s.spd_role)))
.ForMember(d => d.PositionCodes, opt => opt.MapFrom(s => GetPositions(s.spd_position_spd_businesscontact.ToArray())))
.ForMember(d => d.ContactId, opt => opt.MapFrom(s => s._spd_contactid_value))
.ForMember(d => d.LicenceId, opt => opt.MapFrom(s => s._spd_swlnumber_value))
.ForMember(d => d.BizId, opt => opt.MapFrom(s => s._spd_organizationid_value))
Expand Down Expand Up @@ -74,5 +76,10 @@ private static (Guid? InviteId, ApplicationInviteStatusEnum? InviteStatus) GetLa
}
}
}

private static IEnumerable<PositionEnum> GetPositions(spd_position[] positions)
{
return positions.Select(p => Enum.Parse<PositionEnum>(DynamicsContextLookupHelpers.LookupPositionKey(p.spd_positionid))).AsEnumerable();
}
}
}
5 changes: 5 additions & 0 deletions src/Spd.Utilities.Dynamics/DynamicsContextLookupHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ public static string LookupLicenceCategoryKey(Guid? licenceCategoryId)
.Where(s => s.statecode != DynamicsConstants.StateCode_Inactive)
.FirstOrDefault();
}

public static string LookupPositionKey(Guid? positionId)
{
return PositionDictionary.FirstOrDefault(s => s.Value == positionId).Key;
}
#endregion

public static async Task<spd_application?> GetApplicationById(this DynamicsContext context, Guid appId, CancellationToken ct)
Expand Down
Loading