Exemple #1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Playlist).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlaylistExists(Playlist.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #2
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();
            }
        }
Exemple #3
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Playlists.Add(Playlist);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Item = await _context.Items.FindAsync(id);

            if (Item != null)
            {
                _context.Items.Remove(Item);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }