RootElement CreateRoot(Actor actor) { if(actor == null) return new RootElement(""){ new Section(){ new StringElement("No Data Available"), } }; var section = new Section("Stats"){ new StringElement("Name",actor.Name), new StringElement("Age",((int)((double)actor.Age.Days/365.2425)).ToString()), new StringElement("Birthday",actor.BirthDate.ToShortDateString()), new StringElement("Height",actor.HeightInMeters.ToString()), }; var bio = new Section("Bio"){ new MultilineElement(actor.Bio), }; var addressSection = new Section("Address"){ new StringElement("Street", actor.Address.Street), new StringElement("City",actor.Address.City), new StringElement("Country",actor.Address.Country), }; var commentSection = new Section("Comments"){ new MultilineElement(actor.Comment ?? ""), }; return new RootElement(actor.Name){ section, bio, addressSection, commentSection, }; }
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 ActorDetailViewController(Actor actor) : base(UITableViewStyle.Grouped,true) { Root = CreateRoot(actor); Title = actor.Name; }