Beispiel #1
0
 public async Task <ActionResult> DeleteAncillaryFile(
     Guid releaseId, Guid fileId)
 {
     return(await _releaseFileService
            .Delete(releaseId, fileId)
            .HandleFailuresOrNoContent());
 }
        private async Task <Either <ActionResult, Unit> > RemoveUnusedImages(Guid releaseId)
        {
            return(await _contentService.GetContentBlocks <HtmlBlock>(releaseId)
                   .OnSuccess(async contentBlocks =>
            {
                var contentImageIds = contentBlocks.SelectMany(contentBlock =>
                                                               HtmlImageUtil.GetReleaseImages(contentBlock.Body))
                                      .Distinct();

                var imageFiles = await _releaseFileRepository.GetByFileType(releaseId, FileType.Image);

                var unusedImages = imageFiles
                                   .Where(file => !contentImageIds.Contains(file.File.Id))
                                   .Select(file => file.File.Id)
                                   .ToList();

                if (unusedImages.Any())
                {
                    return await _releaseFileService.Delete(releaseId, unusedImages);
                }

                return Unit.Instance;
            }));
        }
Beispiel #3
0
 public async Task <Either <ActionResult, Unit> > RemoveChartFile(Guid releaseId, Guid id)
 {
     return(await RemoveInfographicChartFromDataBlock(releaseId, id)
            .OnSuccess(async() => await _releaseFileService.Delete(releaseId, id)));
 }