public async Task <ActionResult <Video> > PostVideo(URLDTO URL) { String videoId = YoutubeHelper.GetVideoIdFromURL(URL.URL); Video newVideo = YoutubeHelper.GetVideoFromId(videoId); _context.Video.Add(newVideo); await _context.SaveChangesAsync(); TranscriptionsController transcriptionsController = new TranscriptionsController(new youtubeContext()); List <Transcription> transcriptions = YoutubeHelper.GetTranscriptions(videoId); //Go through each transaction and insert it into the database by calling PostTransactions() Task addCaptions = Task.Run(async() => { for (int i = 0; i < transcriptions.Count; i++) { Transcription transcription = transcriptions.ElementAt(i); transcription.VideoId = newVideo.VideoId; await transcriptionsController.PostTranscription(transcription); Console.WriteLine("inserting transcription" + i); } }); return(CreatedAtAction("GetVideo", new { id = newVideo.VideoId }, newVideo)); }