Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
kjetilhau committed Oct 30, 2024
1 parent c924181 commit 9370be3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@

namespace Equinor.ProjectExecutionPortal.Application.Services.AppService
{
public class AppService(IFusionAppsService fusionAppsService) : IAppService
public class AppService : IAppService
{
private readonly IFusionAppsService _fusionAppsService;

public AppService(IFusionAppsService fusionAppsService)
{
_fusionAppsService = fusionAppsService;
}

public async Task<OnboardedAppDto> EnrichWithFusionAppData(OnboardedAppDto onboardedApp, CancellationToken cancellationToken)
{
if (onboardedApp.AppKey == null)
{
return onboardedApp;
}

var fusionApp = await fusionAppsService.GetFusionApp(onboardedApp.AppKey);
var fusionApp = await _fusionAppsService.GetFusionApp(onboardedApp.AppKey);

if (fusionApp != null)
{
Expand All @@ -25,7 +32,7 @@ public async Task<OnboardedAppDto> EnrichWithFusionAppData(OnboardedAppDto onboa

public async Task<IList<OnboardedAppDto>> EnrichWithFusionAppData(IList<OnboardedAppDto> onboardedApps, CancellationToken cancellationToken)
{
var fusionApps = await fusionAppsService.GetFusionApps();
var fusionApps = await _fusionAppsService.GetFusionApps();

foreach (var onboardedApp in onboardedApps)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class ContextService : IContextService
{
private readonly IFusionContextResolver _fusionContextResolver;


public ContextService(IFusionContextResolver contextResolver)
{
_fusionContextResolver = contextResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@

namespace Equinor.ProjectExecutionPortal.Application.Services.ContextTypeService
{
public class ContextTypeService(IReadWriteContext readWriteContext) : IContextTypeService
public class ContextTypeService : IContextTypeService
{
private readonly IReadWriteContext _readWriteContext;

public ContextTypeService(IReadWriteContext readWriteContext)
{
_readWriteContext = readWriteContext;
}

public async Task<IList<ContextType>> GetAllowedContextTypesByKeys(IList<string> contextTypeKeys, CancellationToken cancellationToken)
{
if (contextTypeKeys.Count == 0)
{
return [];
}

var availableContextTypes = await readWriteContext.Set<ContextType>().ToListAsync(cancellationToken);
var availableContextTypes = await _readWriteContext.Set<ContextType>().ToListAsync(cancellationToken);

var invalidContextTypes = contextTypeKeys.FirstOrDefault(key => !availableContextTypes.Select(contextType => contextType.ContextTypeKey).Contains(key));

Expand All @@ -28,4 +35,4 @@ public async Task<IList<ContextType>> GetAllowedContextTypesByKeys(IList<string>
return addContextTypes.ToList();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@

namespace Equinor.ProjectExecutionPortal.Application.Services.PortalService
{
public class PortalService(IMapper mapper) : IPortalService
public class PortalService : IPortalService
{
private readonly IMapper _mapper;

public PortalService(IMapper mapper)
{
_mapper = mapper;
}

public IList<PortalOnboardedAppDto> CombinePortalAppsWithOnboardedApps(Portal portal, IList<OnboardedApp> onboardedApps, CancellationToken cancellationToken)
{
var portalAppsDto = mapper.Map<List<PortalApp>, List<PortalOnboardedAppDto>>(GetDistinctPortalApps(portal.Apps.ToList()));
var portalAppsDto = _mapper.Map<List<PortalApp>, List<PortalOnboardedAppDto>>(GetDistinctPortalApps(portal.Apps.ToList()));

SetAppsAsActiveInPortal(portalAppsDto);

Expand All @@ -33,7 +40,7 @@ public PortalOnboardedAppDto GetPortalOnboardedAppNotActive(OnboardedApp onboard
{
return new PortalOnboardedAppDto
{
OnboardedApp = mapper.Map<OnboardedApp, OnboardedAppDto>(onboardedApp),
OnboardedApp = _mapper.Map<OnboardedApp, OnboardedAppDto>(onboardedApp),
IsActive = false
};
}
Expand Down Expand Up @@ -79,7 +86,7 @@ private List<PortalOnboardedAppDto> GetOnBoardedAppsNotActiveInPortal(Portal por

return onBoardedAppsNotActiveInPortal.Select(onBoardedApp => new PortalOnboardedAppDto()
{
OnboardedApp = mapper.Map<OnboardedApp, OnboardedAppDto>(onBoardedApp),
OnboardedApp = _mapper.Map<OnboardedApp, OnboardedAppDto>(onBoardedApp),
IsActive = false
}).ToList();
}
Expand All @@ -89,4 +96,4 @@ private static bool IsContextualPortal(Portal portal)
return portal.ContextTypes.Count > 0;
}
}
}
}

0 comments on commit 9370be3

Please sign in to comment.