Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("GameId,GenreId,Title,ReleaseDate")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(game));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("MyGamesId,GameID,ReviewGrade,Review,ReviewDate")] MyGames myGames)
        {
            if (ModelState.IsValid)
            {
                _context.Add(myGames);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameID"] = new SelectList(_context.Game, "GameId", "GameId", myGames.GameID);
            return(View(myGames));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("GenreId,GameGenre,CreateDate,EditDate")] Genre genre)
        {
            bool CheckGenreName = VideoGamesGenre.GenreExistsName(_context, genre.GameGenre);

            if (CheckGenreName)
            {
                ModelState.AddModelError("GameGenre", "Genre Already Exists.");
            }

            if (ModelState.IsValid)
            {
                var currentDateTime = DateTime.Now;
                var date            = currentDateTime.Date;
                genre.CreateDate = DateTime.Now.Date; //doesnt make sense to have user set these when I know what they should be
                genre.EditDate   = DateTime.Now.Date; //doesnt make sense to have user set these when I know what they should be
                _context.Add(genre);
                await _context.SaveChangesAsync();

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