public async Task <IActionResult> PutConsolePhotostock(int id, ConsolePhotostock consolePhotostock)
        {
            if (id != consolePhotostock.Id)
            {
                return(BadRequest());
            }

            _context.Entry(consolePhotostock).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ConsolePhotostockExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <ConsolePhotostock> > PostConsolePhotostock(ConsolePhotostock consolePhotostock)
        {
            _context.Photostocks.Add(consolePhotostock);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetConsolePhotostock", new { id = consolePhotostock.Id }, consolePhotostock));
        }
Beispiel #3
0
        // Seed
        public static void InsertData(bool isFirstTime)
        {
            using var context = new AppContext();
            if (isFirstTime)
            {
                context.Database.EnsureDeleted();
            }

            // Creates the database if not exists
            context.Database.EnsureCreated();

            var p1 = new Playlist
            {
                PlaylistId   = "spotify:playlist:37i9dQZF1DWUbycBFSWTh7",
                PlaylistName = "Deephouse Delight",
                //Mood = 7
            };
            var p2 = new Playlist
            {
                PlaylistId   = "spotify:playlist:37i9dQZF1DWUq3wF0JVtEy",
                PlaylistName = "Shuffle Syndrome",
                //Mood = 8
            };

            context.Playlists.AddRange(p1, p2);

            var cp1 = new ConsolePhotostock {
                Url = "https://www.deviantart.com/topic/photo-manipulation"
            };
            var cp2 = new ConsolePhotostock {
                Url = "https://www.deviantart.com/topic/digital-art"
            };

            context.Photostocks.AddRange(cp1, cp2);

            var pt1 = new PostedTrack
            {
                Trackname = "Martin Garrix - Animals (remix)",
                Date      = DateTime.Now,
                Playlist  = p1
            };
            var pt2 = new PostedTrack
            {
                Trackname = "Disturbed - On my own",
                Date      = DateTime.Now,
                Playlist  = p2,
            };

            context.PostedTracks.AddRange(pt1, pt2);

            var pp1 = new PostedPhoto
            {
                Url = "https://test.jpg/",
            };

            context.PostedPhotos.Add(pp1);

            //var post1 = new Post
            //{
            //    Message = "#EDM",
            //    PublishDate = DateTime.Now,
            //    PostedTracks = { pt1, pt2 },
            //    //PostId = 1,
            //    OwnerId = 1,
            //    PostedPhotos = { pp1 }
            //};
            //context.Posts.Add(post1);

            var ut1 = new UnfoundTrack {
                Trackname = "KVPV - Inferno", Playlist = p1
            };
            var ut2 = new UnfoundTrack {
                Trackname = "AC/DC - Paradise", Playlist = p2
            };

            context.UnfoundTracks.AddRange(ut1, ut2);

            var xpath = new ParserXpath {
                Xpath = "//*[@id=\"root\"]/div[1]/div/div/div/article/div/div[2]/div/div", XpathInner = ""
            };

            context.ParserXpaths.Add(xpath);
            // Saves changes
            context.SaveChanges();
        }