예제 #1
0
        public async Task <IActionResult> Create([Bind("SongId,AlbumId,Title,ArtistName,Featuring,RunTime")] Song song)
        {
            if (ModelState.IsValid)
            {
                _context.Add(song);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(song));
        }
        public async Task <IActionResult> Create([Bind("GenreId,Name")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(genre));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,Artist,Title,Length")] MusicTrack musicTrack)
        {
            if (ModelState.IsValid)
            {
                _context.Add(musicTrack);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(musicTrack));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price")] Music music)
        {
            if (ModelState.IsValid)
            {
                _context.Add(music);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(music));
        }
        public async Task <IActionResult> Create([Bind("AlbumId,GenreId,Title,Artist,ReleaseDate")] Album album)
        {
            if (ModelState.IsValid)
            {
                _context.Add(album);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(album));
        }
        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.Artists, "ArtistId", "ArtistId", album.ArtistId);
            ViewData["GenreId"]  = new SelectList(_context.Genres, "GenreId", "GenreId", album.GenreId);
            return(View(album));
        }
        public async Task <IActionResult> Create([Bind("SongId,AlbumId,Title,Featuring,Price")] Song song)
        {
            if (song.Price <= 0)
            {
                throw new InvalidOperationException();
            }
            if (ModelState.IsValid)
            {
                _context.Add(song);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(song));
        }