private PresentationResponse NoSongResponse(IEnumerable <Song> songs)
        {
            var presentationResponse = new PresentationResponse();

            presentationResponse.CreateExceptionResponse(songs, MagicString.NoSongSelected);
            return(presentationResponse);
        }
        public IActionResult Presentation([FromQuery] List <int> ids)
        {
            IEnumerable <Song> songs = new List <Song>();

            try
            {
                songs = _songRepository.GetSongsInOrder(ids);
                if (!songs.Any())
                {
                    return(BadRequest(NoSongResponse(songs)));
                }

                var mergedPptxPresentationOnLocalhost = _powerPointMerger.Merge(songs);
                var mergedPresentation = _googleSlides.AddPptxFile(mergedPptxPresentationOnLocalhost);

                var response = CreateResponseForPptxAndHistoryLog(mergedPresentation, songs);

                System.IO.File.Delete(mergedPptxPresentationOnLocalhost);
                return(Ok(response));
            }
            catch (Exception ex)
            {
                var presentationResponse = new PresentationResponse();
                presentationResponse.CreateExceptionResponse(songs, ex.Message);
                return(BadRequest(presentationResponse));
            }
        }
        private PresentationResponse CreateResponseForPptxAndHistoryLog(PresentationOnDrive presentationOnDrive, IEnumerable <Song> songs)
        {
            var presentationResponse = new PresentationResponse();
            var presentation         = CreatePresentationWithLinksToSongs(presentationOnDrive, songs);

            var presentationDto = Mapper.Map <PresentationDto>(presentation);

            presentationResponse.CreateSuccessResponse(presentationDto);
            return(presentationResponse);
        }
        private PresentationResponse CreateResponseForZipAndHistoryLog(PresentationOnDrive zippedPresentation, Presentation presentation)
        {
            var presentationResponse = new PresentationResponse();

            presentation.GoogleDriveZipFileId = zippedPresentation.FileId;
            _presentationRepository.Save();

            var presentationDto = Mapper.Map <PresentationDto>(presentation);

            presentationResponse.CreateSuccessResponse(presentationDto);
            return(presentationResponse);
        }
        public IActionResult Presentation(string googleDriveFileId)
        {
            try
            {
                var presentation = _presentationRepository.Get(googleDriveFileId);
                var pptxMergedFileOnLocalhost = _googleSlides.DownloadPptx(presentation, googleDriveFileId);

                var zippedPresentationOnLocalhost = _pptxToZipConverter.Convert(pptxMergedFileOnLocalhost);
                var zippedPresentation            = _googleSlides.AddZipFile(zippedPresentationOnLocalhost);

                var response = CreateResponseForZipAndHistoryLog(zippedPresentation, presentation);

                System.IO.File.Delete(pptxMergedFileOnLocalhost);
                System.IO.File.Delete(zippedPresentationOnLocalhost);
                return(Ok(response));
            }
            catch (Exception ex)
            {
                var presentationResponse = new PresentationResponse();
                presentationResponse.CreateExceptionResponse(null, ex.Message);
                return(BadRequest(presentationResponse));
            }
        }