public async Task <ICollection <SummarisedActual> > FundingDataRemovedAsync(string organisationId, ICollection <SummarisedActual> providerActuals, ISummarisationMessage summarisationMessage, CancellationToken cancellationToken) { var latestCollectionReturn = await _summarisedActualsProcessRepository.GetLastCollectionReturnForReRunAsync(summarisationMessage.CollectionType, summarisationMessage.CollectionReturnCode, cancellationToken); var actualsToCarry = new List <SummarisedActual>(); if (latestCollectionReturn != null) { var previousActuals = await _summarisedActualsProcessRepository.GetSummarisedActualsAsync(latestCollectionReturn.Id, organisationId, cancellationToken); var comparer = new CarryOverActualsComparer(); actualsToCarry = previousActuals.Except(providerActuals, comparer).ToList(); foreach (var actuals in actualsToCarry) { actuals.ActualVolume = 0; actuals.ActualValue = 0; } } return(actualsToCarry); }
public async Task PublishAsync(ISummarisationMessage summarisationMessage, CancellationToken cancellationToken) { var collectionReturn = await _summarisedActualsRepository.GetLastCollectionReturnAsync(summarisationMessage.CollectionType, summarisationMessage.CollectionReturnCode, cancellationToken); var eventLog = _eventLogMapper.Map(collectionReturn); _logger.LogInfo($"Publish to BAU: Retrieving and storing data to BAU Start"); var summarisedActuals = await _summarisedActualsRepository.GetSummarisedActualsAsync(collectionReturn.Id, cancellationToken); var summarisedActualsBAU = _summarisedActualMapper.Map(summarisedActuals, summarisationMessage.CollectionType, summarisationMessage.CollectionReturnCode); await _dataStorePersistenceService.StoreSummarisedActualsDataAsync( summarisedActualsBAU, eventLog, cancellationToken); _logger.LogInfo($"Publish to BAU: Retrieving and storing data to BAU End"); }