Esempio n. 1
0
        public async Task <IActionResult> PutArtist([FromRoute] int id, [FromBody] Artist artist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != artist.ArtistId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("AlbumID,GenreID,ArtistID,Title,Price,AlbumArtUri")] Album album)
        {
            if (ModelState.IsValid)
            {
                _context.Add(album);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArtistID"] = new SelectList(_context.Set <Artist>(), "ArtistID", "ArtistID", album.ArtistID);
            ViewData["GenreID"]  = new SelectList(_context.Set <Genre>(), "GenreID", "GenreID", album.GenreID);
            return(View(album));
        }