private static void PopulateStorage(Filmography filmography) { filmography.AddActorFilm("Paul Walker", "The Fast and Furious"); filmography.AddActorFilm("Paul Walker", "Running Scared"); filmography.AddActorFilm("Al Pacino", "Scarface"); filmography.AddActorFilm("Al Pacino", "Heat"); filmography.AddActorFilm("Kevin Spacey", "Se7en"); filmography.AddActorFilm("Kevin Spacey", "K-Pax"); }
static void Main(string[] args) { Console.WriteLine("Welcome to the Actor Filmography Reference!"); Console.Write("Please Enter an Actor's Name: "); var input = Console.ReadLine(); var filmography = new Filmography(); PopulateStorage(filmography); Console.Clear(); Console.WriteLine("{0} was featured in:", input); foreach (var movie in filmography.GetActorFilms(input)) { Console.WriteLine(movie); } Console.Read(); }
/// <summary> /// Parses fields that are common for all Filmography types. /// </summary> /// <param name="Filmography"></param> /// <param name="filmographyObj"></param> /// <param name="includeExternalIds"></param> private void ParseFilmography(Filmography filmography, JObject filmographyObj, Boolean includeExternalIds) { JToken value; if ((value = get(filmographyObj, MovieDataClient.KEY.TMDB_ID)) != null) { filmography.TmdbId = (int)value; } if ((value = get(filmographyObj, MovieDataClient.KEY.POSTER_PATH)) != null) { filmography.PosterPath = (string)value; } if (!string.IsNullOrEmpty((string)(value = get(filmographyObj, MovieDataClient.KEY.VOTE_AVERAGE)))) { filmography.VoteAverage = float.Parse((string)value); } if ((value = get(filmographyObj, MovieDataClient.KEY.OVERVIEW)) != null) { filmography.Overview = (string)value; } // release date can occur under different keys filmography.Title = ParseTitle(filmographyObj); // release date can occur under different keys filmography.SetReleaseDate(ParseReleaseDate(filmographyObj)); if (includeExternalIds) { JToken externalIds = get(filmographyObj, MovieDataClient.KEY.EXTERNAL_IDS); if (externalIds != null && (value = get(externalIds, MovieDataClient.KEY.IMDB_ID)) != null) { filmography.ImdbId = (string)value; } } }
internal bool SaveFilmography <T>(T entity, bool newFilmographyToUser) where T : Filmography, new() { Filmography existing = null; FilmographyType.Value type; TableQuery <T> query = Connection.Table <T>().Where(f => f.TmdbId == entity.TmdbId); existing = query.Count() > 0 ? query.First() : null; if (entity is Series) { type = FilmographyType.Value.SERIES; } else if (entity is Season) { type = FilmographyType.Value.SEASON; } else if (entity is Episode) { type = FilmographyType.Value.EPISODE; } else { throw new NotSupportedException(); } if (existing == null) { if (Connection.Insert(entity) == 0) { return(false); } } else { entity.Id = existing.Id; if (Connection.Update(entity) == 0) { return(false); } } if (newFilmographyToUser) { FilmographyToUser ftu = new FilmographyToUser(); ftu.FilmographyId = entity.GetId(); ftu.FilmographyTypeId = (int)type; ftu.UserId = App.Instance.User.GetId(); ftu.Finished = false; ftu.SecondsWatched = 0; ftu.SetLastActivityDate(DateTime.Now); ftu.PrintValues(); TableQuery <FilmographyToUser> ftuQuery = Connection.Table <FilmographyToUser>().Where( f => f.UserId == ftu.UserId && f.FilmographyId == ftu.FilmographyId && f.FilmographyTypeId == ftu.FilmographyTypeId); FilmographyToUser existingFtu = ftuQuery.Count() > 0 ? ftuQuery.First() : null; if (existingFtu == null) { if (Connection.Insert(ftu) == 0) { return(false); } } else { ftu.Id = existingFtu.Id; if (Connection.Update(ftu) == 0) { return(false); } } } return(true); }
private void ParseFilmography(Filmography filmography, Boolean includeExternalIds) { ParseFilmography(filmography, jsonObject, includeExternalIds); }