예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("MyGamesId,GameID,ReviewGrade,Review,ReviewDate")] MyGames myGames)
        {
            if (id != myGames.MyGamesId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(myGames);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MyGamesExists(myGames.MyGamesId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameID"] = new SelectList(_context.Game, "GameId", "GameId", myGames.GameID);
            return(View(myGames));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("GameId,GenreId,Title,ReleaseDate")] Game game)
        {
            if (id != game.GameId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(game);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameExists(game.GameId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(game));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("GenreId,GameGenre,EditDate")] Genre genre)
        {
            if (id != genre.GenreId)
            {
                return(NotFound());
            }

            bool CheckGenreName = VideoGamesGenre.GenreExistsName(_context, genre.GameGenre);

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

            if (ModelState.IsValid)
            {
                try
                {
                    var currentDateTime = DateTime.Now;
                    var date            = currentDateTime.Date;
                    genre.EditDate = date;//doesnt make sense to have user set these when I know what they should be, not allowing edit on create
                    _context.Update(genre);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenreExists(genre.GenreId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(genre));
        }