예제 #1
0
        private PresentationResponse NoSongResponse(IEnumerable <Song> songs)
        {
            var presentationResponse = new PresentationResponse();

            presentationResponse.CreateExceptionResponse(songs, MagicString.NoSongSelected);
            return(presentationResponse);
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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));
            }
        }