Esempio n. 1
0
        static async Task AddRoundsToProjects()
        {
            using (var context = CreateContext())
            {
                var projects = await context.Projects.ToListAsync();

                foreach (var project in projects)
                {
                    var round = new Round
                    {
                        CreatedOn   = DateTime.Now,
                        State       = RoundState.Published,
                        RoundNumber = "Round 1",
                    };

                    int index = 0;

                    round.Add(new Content
                    {
                        ContentIndex = index++,
                        Description  = "Photobomb goat",
                        ContentUrl   = "http://s3-ec.buzzfed.com/static/enhanced/terminal05/2012/5/10/12/enhanced-buzz-7611-1336668483-0.jpg",
                    });
                    round.Add(new Content
                    {
                        ContentIndex = index++,
                        Description  = "Photobomb cat",
                        ContentUrl   = "http://s3-ec.buzzfed.com/static/enhanced/terminal05/2012/5/10/12/enhanced-buzz-7573-1336668523-2.jpg",
                    });
                    round.Add(new Content
                    {
                        ContentIndex = index++,
                        Description  = "Photobomb bear",
                        ContentUrl   = "http://s3-ec.buzzfed.com/static/enhanced/web04/2012/5/10/16/enhanced-buzz-24345-1336682077-8.jpg",
                    });
                    round.Add(new Content
                    {
                        ContentIndex = index++,
                        Description  = "Photobomb hippo",
                        ContentUrl   = "http://s3-ec.buzzfed.com/static/enhanced/terminal05/2012/5/10/12/enhanced-buzz-6968-1336668519-2.jpg",
                    });

                    project.Add(round);


                    // add a 2nd round
                    round = new Round
                    {
                        CreatedOn   = DateTime.Now + TimeSpan.FromHours(5),
                        State       = RoundState.Published,
                        RoundNumber = "Round 2",
                    };

                    index = 0;

                    round.Add(new Content
                    {
                        ContentIndex = index++,
                        Description  = "Bat-Cow",
                        ContentUrl   = "http://comicbook.com/wp-content/uploads/2013/05/bat-cow.png",
                    });
                    round.Add(new Content
                    {
                        ContentIndex = index++,
                        Description  = "Baby seals",
                        ContentUrl   = "http://i.imgur.com/fELVKnI.jpg",
                    });
                    round.Add(new Content
                    {
                        ContentIndex = index++,
                        Description  = "Fat cat",
                        ContentUrl   = "http://i.imgur.com/TO1hUlp.jpg",
                    });


                    project.Add(round);
                }

                await context.SaveChangesAsync();
            }
        }