コード例 #1
0
        public async static Task Init(IServiceProvider serviceProvider)
        {
            using (var context = new ScreensContext(serviceProvider.GetRequiredService <DbContextOptions <ScreensContext> >()))
            {
                if (context.Playlists.Any())
                {
                    return;
                }

                Playlist[] playlists =
                {
                    new Playlist {
                        Name = "Default"
                    }
                    , new Playlist{
                        Name = "Hanan"
                    }
                    , new Playlist{
                        Name = "Shoemaker"
                    }
                };

                await context.Playlists.AddRangeAsync(playlists);

                await context.SaveChangesAsync();

                await context.Items.AddRangeAsync(
                    new Item { Name = "SquadGoals", Blob = "https://media.giphy.com/media/5t0xCMZaJZXCUYtTjE/source.gif", Playlist = playlists.First() }
                    , new Item { Name = "Redonk", Blob = "https://media.giphy.com/media/7zxZFU3YYgHBM61wmb/giphy.gif", Playlist = playlists.First() }
                    , new Item { Name = "Challange Accepted", Blob = "https://media.giphy.com/media/3oKIPmMXKTqCujivh6/source.gif", Playlist = playlists.First() }
                    , new Item { Name = "Soemthing Bad", Blob = "https://media.giphy.com/media/mkh6jp4TRnxZHSVG2e/giphy.gif", Playlist = playlists.First() }
                    , new Item { Name = "Woah", Blob = "https://media.giphy.com/media/YWVdqPBhhheHEK8yOK/giphy.gif", Playlist = playlists.First() }
                    , new Item { Name = "OK", Blob = "https://media.giphy.com/media/3ov9jJxWL1I9vj6R7q/giphy.gif", Playlist = playlists.First() }
                    , new Item { Name = "Excited", Blob = "https://media.giphy.com/media/2sdKWZkj8kDxOGcntY/source.gif", Playlist = playlists.First() }
                    , new Item { Name = "What is this even?", Blob = "https://media.giphy.com/media/3gLeFdMptotQcRIR4x/source.gif", Playlist = playlists.First() }

                    , new Item { Name = "Hell Raising", Blob = "https://media.giphy.com/media/fdDqMvPMg4E54Tcuy6/giphy.gif", Playlist = playlists[1] }
                    , new Item { Name = "LOLed", Blob = "http://giphygifs.s3.amazonaws.com/media/aHlnxCpJUIDM4/giphy.gif", Playlist = playlists[1] }
                    , new Item { Name = "Adorable", Blob = "https://media.giphy.com/media/Xkh5ZzxiIKfgk/source.gif", Playlist = playlists[1] }
                    , new Item { Name = "Who are you even", Blob = "https://media.giphy.com/media/ziBnl6v3T8Mjm/source.gif", Playlist = playlists[1] }
                    , new Item { Name = "i am funny", Blob = "https://media.giphy.com/media/P6ONpz0bAieoE/source.gif", Playlist = playlists[1] }
                    );

                await context.SaveChangesAsync();
            }
        }
コード例 #2
0
 public DeleteModel(ScreensEverywhere.Data.ScreensContext context)
 {
     _context = context;
 }
コード例 #3
0
 public IndexModel(ScreensEverywhere.Data.ScreensContext context)
 {
     _context = context;
 }