RootElement CreateRoot(Movie movie) { var topSection = new Section("Details"){ new StringElement("Title",movie.Title), new StringElement("Release Date", movie.ReleaseDate.ToShortDateString()), }; var actorSection = new Section("Actors"); foreach(var actor in movie.ActorNames) { var theActor = actor; actorSection.Add(new StringElement(actor,delegate{ ActivateController(new ActorDetailViewController(theActor)); })); } return new RootElement(movie.Title){ topSection, actorSection, }; }
public static void PopulateMovies() { Console.WriteLine("Creating the context object"); DynamoDBContext context = new DynamoDBContext(Database.Client); Console.WriteLine("Creating actors"); Actor christianBale = new Actor { Name = "Christian Bale", Bio = "Christian Charles Philip Bale is an excellent horseman and an avid reader.", BirthDate = new DateTime(1974, 1, 30), Address = new Address { City = "Los Angeles", Country = "USA" }, HeightInMeters = 1.83f }; Actor michaelCaine = new Actor { Name = "Michael Caine", Bio = "Maurice Joseph Micklewhite is an English actor, better known as Michael Caine", BirthDate = new DateTime(1933, 3, 14), Address = new Address { City = "London", Country = "England" }, HeightInMeters = 1.88f }; Console.WriteLine("Creating movie"); Movie darkKnight = new Movie { Title = "The Dark Knight", ReleaseDate = new DateTime(2008, 7, 18), Genres = new List<string> { "Action", "Crime", "Drama" }, ActorNames = new List<string> { christianBale.Name, michaelCaine.Name } }; Console.WriteLine("Saving actors and movie"); context.Save<Actor>(michaelCaine); context.Save<Actor>(christianBale); context.Save<Movie>(darkKnight); Console.WriteLine("Creating and saving new actor"); Actor maggieGyllenhaal = new Actor { Name = "Maggie Gyllenhaal", BirthDate = new DateTime(1977, 11, 16), Bio = "Maggie Gyllenhaal studied briefly at the Royal Academy of Dramatic Arts in London.", Address = new Address { City = "New York City", Country = "USA" }, HeightInMeters = 1.75f }; context.Save<Actor>(maggieGyllenhaal); Console.WriteLine(); Console.WriteLine("Loading existing movie"); Movie existingMovie = context.Load<Movie>("The Dark Knight", new DateTime(2008, 7, 18)); Console.WriteLine(existingMovie.ToString()); Console.WriteLine(); Console.WriteLine("Loading nonexistent movie"); Movie nonexistentMovie = context.Load<Movie>("The Dark Knight", new DateTime(2008, 7, 19)); Console.WriteLine("Movie is null : " + (nonexistentMovie == null)); Console.WriteLine("Updating movie and saving"); existingMovie.ActorNames.Add(maggieGyllenhaal.Name); existingMovie.Genres.Add("Thriller"); context.Save<Movie>(existingMovie); Console.WriteLine("Adding movie with same hash key but different range key"); Movie darkKnight89 = new Movie { Title = "The Dark Knight", Genres = new List<string> { "Drama" }, ReleaseDate = new DateTime(1989, 2, 23), ActorNames = new List<string> { "Juan Diego", "Fernando Guillén", "Manuel de Blas" } }; context.Save<Movie>(darkKnight89); }
public MovieDetailController(Movie movie) : base(UITableViewStyle.Grouped,true) { this.Title = movie.Title; Movie = movie; }