public PresentationOnDrive AddZipFile(string filePath) { var fileMetadata = new File() { Name = Path.GetFileName(filePath), Parents = new List <string> { _folderForZip } }; FilesResource.CreateMediaUpload request; using (var stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open)) { request = _driveService.Files.Create( fileMetadata, stream, "application/zip"); request.Fields = "id"; request.Upload(); } var file = request.ResponseBody; var presentationOnDrive = new PresentationOnDrive() { Name = Path.GetFileName(filePath), Extension = "Zip", FileId = file.Id }; return(presentationOnDrive); }
public PresentationOnDrive AddPptxFile(string filePath) { var fileMetadata = new File() { Name = Path.GetFileName(filePath), Parents = new List <string> { _folderForPptx } }; FilesResource.CreateMediaUpload request; using (var stream = new FileStream(filePath, FileMode.Open)) { request = _driveService.Files.Create( fileMetadata, stream, "application/vnd.openxmlformats-officedocument.presentationml.presentation"); request.Fields = "id"; request.Upload(); } var file = request.ResponseBody; var presentationOnDrive = new PresentationOnDrive() { Name = Path.GetFileName(filePath), Extension = "Pptx", FileId = file.Id }; return(presentationOnDrive); }
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); }
private Presentation CreatePresentationWithLinksToSongs(PresentationOnDrive presentationOnDrive, IEnumerable <Song> songs) { var presentation = new Presentation(presentationOnDrive.FileId, GetUserInformation()); var list = new List <LinkSongToPresentation>(); foreach (var song in songs) { var link = new LinkSongToPresentation() { Presentation = presentation, Song = song }; list.Add(link); song.LinkSongToPresentation.Add(link); } presentation.LinkSongToPresentation.AddRange(list); _presentationRepository.Save(); return(presentation); }