コード例 #1
0
        public async Task <IActionResult> Create([Bind("id,Title,ReleaseDate,Genre,Price,locationID")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(game));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("locationID,City")] Location location)
        {
            if (ModelState.IsValid)
            {
                _context.Add(location);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,ReleaseDate,Genre,Rating")] Game game)
        {
            game.Rating = _context.Rating.Where(r => r.Rating == game.Rating.Rating).FirstOrDefault();
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

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