コード例 #1
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));
        }
コード例 #2
0
ファイル: StoreManagerController.cs プロジェクト: StarUni/XC
        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));
        }