Skip to content

Commit

Permalink
APR-1152 added in async
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkFCain committed Aug 27, 2020
1 parent bef548a commit b488c17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using SFA.DAS.ApplyService.Web.Configuration;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SFA.DAS.ApplyService.Web.Services
{
public interface INotRequiredOverridesService
{
void RefreshNotRequiredOverrides(Guid applicationId);
Task RefreshNotRequiredOverrides(Guid applicationId);
List<NotRequiredOverrideConfiguration> GetNotRequiredOverrides(Guid applicationId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using SFA.DAS.ApplyService.Application.Apply.Roatp;
using NotRequiredOverrideConfiguration = SFA.DAS.ApplyService.Web.Configuration.NotRequiredOverrideConfiguration;
Expand All @@ -30,15 +31,15 @@ public NotRequiredOverridesService(IOptions<List<NotRequiredOverrideConfiguratio
_sessionService = sessionService;
}

public void RefreshNotRequiredOverrides(Guid applicationId)
public async Task RefreshNotRequiredOverrides(Guid applicationId)
{
RemoveConfigurationFromCache(applicationId);
var configuration = CalculateNotRequiredOverrides(applicationId);
var configuration = await CalculateNotRequiredOverrides(applicationId);
var applicationNotRequiredOverrides = new Application.Apply.Roatp.NotRequiredOverrideConfiguration
{
NotRequiredOverrides = Mapper.Map<List<NotRequiredOverride>>(configuration)
};
_applicationApiClient.UpdateNotRequiredOverrides(applicationId, applicationNotRequiredOverrides);
_applicationApiClient.UpdateNotRequiredOverrides(applicationId, applicationNotRequiredOverrides).GetAwaiter().GetResult();
SaveConfigurationToCache(applicationId, configuration);
}

Expand All @@ -55,16 +56,16 @@ public List<NotRequiredOverrideConfiguration> GetNotRequiredOverrides(Guid appli
return configuration;
}

private List<NotRequiredOverrideConfiguration> CalculateNotRequiredOverrides(Guid applicationId)
private async Task<List<NotRequiredOverrideConfiguration>> CalculateNotRequiredOverrides(Guid applicationId)
{
List<NotRequiredOverrideConfiguration> configuration = null;

var applicationData = _qnaApiClient.GetApplicationData(applicationId).GetAwaiter().GetResult() as JObject;

if (applicationData != null)
{
var applicationNotRequiredOverrides =
_applicationApiClient.GetNotRequiredOverrides(applicationId).Result;
var applicationNotRequiredOverrides =await _applicationApiClient.GetNotRequiredOverrides(applicationId);


if (applicationNotRequiredOverrides == null)
{
Expand Down

0 comments on commit b488c17

Please sign in to comment.