Exemple #1
0
        public async Task <IActionResult> Create([Bind("GenreId,Name,Description")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(genre));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ArtistId,Name")] Artist artist)
        {
            if (ModelState.IsValid)
            {
                _context.Add(artist);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(artist));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("AlbumId,GenreId,ArtistId,Title,Price,AlbumArtUrl")] 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));
        }