Skip to content

Commit

Permalink
fix: Use GetContextRelationsAsync in externalid service (#1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
taustad committed Aug 29, 2023
1 parent 2711a50 commit 1f1a0ad
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions backend/api/Services/FusionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,38 @@ public async Task<FusionContext> ProjectMasterAsync(string contextId)
return projectMasterContext;
}

private FusionContext GetProjectMasterContextFromFusionContext(FusionContext fusionContext)
{
if (fusionContext.Type.Name == "ProjectMaster")
{
return fusionContext;
}

return null;
}

private async Task<FusionContext> ResolveProjectMasterContext(string contextId)
{
FusionContext projectMasterContext = await _fusionContextResolver.ResolveContextAsync(contextId, FusionContextType.ProjectMaster);

try
{
var contextRelationships = await _fusionContextResolver.GetContextRelationsAsync(Guid.Parse(contextId));
FusionContext projectMasterFusionContext = null;
foreach (var fusionContext in contextRelationships)
{
projectMasterFusionContext = GetProjectMasterContextFromFusionContext(fusionContext);
if (projectMasterFusionContext != null)
{
return projectMasterFusionContext;
}
}
}
catch (Exception e)
{
Console.WriteLine("ResolveProjectMasterContext - Exception: " + e);
}

Console.WriteLine("ResolveProjectMasterContext - contextId: " + contextId);
Console.WriteLine("ResolveProjectMasterContext - projectMasterContext: " + projectMasterContext);
// It might be the GUID provided was the ProjectMaster ID and not the GUID of the Fusion Context. Will
Expand Down

0 comments on commit 1f1a0ad

Please sign in to comment.