/// <summary> /// Get alll the shows and then their respective casts. Filtered with existing shows already in the database. /// </summary> /// <returns>List<TVShow></returns> private async Task <List <TVShow> > getShowsToInsert() { List <TVShow> showlist = await ApiHelpers.getAllShowsAsync(); var existingShows = _context.TVShow.ToDictionary(m => m.id, m => m); var showDictionary = showlist.ToDictionary(m => m.id, m => m); var showListToInsert = showDictionary.Where(d => !existingShows.ContainsKey(d.Key)).Select(m => m.Value).ToList(); return(await ApiHelpers.UpdateCastsAsync(showListToInsert)); }