diff --git a/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataBlockService.cs b/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataBlockService.cs index 8366c78f0a..2d3237ff71 100644 --- a/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataBlockService.cs +++ b/src/GovUk.Education.ExploreEducationStatistics.Admin/Services/DataBlockService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using AutoMapper; +using GovUk.Education.ExploreEducationStatistics.Admin.Cache; using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces; using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces.Cache; using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces.Security; @@ -217,7 +218,7 @@ public async Task> Update( .OnSuccessDo(dataBlock => _userService.CheckCanUpdateReleaseVersion(dataBlock.ReleaseVersion)) .OnSuccessDo(async dataBlockVersion => { - // TODO EES-753 Alter this when multiple charts are supported + // Remove old infographic file if using a new file var infographicChart = dataBlockVersion.Charts.OfType().FirstOrDefault(); var updatedInfographicChart = updateRequest.Charts.OfType().FirstOrDefault(); @@ -229,6 +230,14 @@ await _releaseFileService.Delete(releaseVersionId: dataBlockVersion.ReleaseVersi fileId: new Guid(infographicChart.FileId)); } + // If has map chart, remove geojson cache + var mapChart = dataBlockVersion.Charts.OfType().FirstOrDefault(); + if (mapChart != null) + { + await _cacheService.DeleteItemAsync( + new LocationsForDataBlockCacheKey(dataBlockVersion, mapChart.BoundaryLevel)); + } + _mapper.Map(updateRequest, dataBlockVersion.ContentBlock); _context.DataBlocks.Update(dataBlockVersion.ContentBlock);