public async Task <IActionResult> Edit(int id, [Bind("Id,GameDateTime,TeamDefendantId,TeamAttackerId")] Game game)
        {
            if (id != game.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(game);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameExists(game.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamAttackerId"]  = new SelectList(_context.Teams, "Id", "TeamName", game.TeamAttackerId);
            ViewData["TeamDefendantId"] = new SelectList(_context.Teams, "Id", "TeamName", game.TeamDefendantId);
            return(View(game));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TeamName,CaptainId")] Team team)
        {
            if (id != team.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(team);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamExists(team.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CaptainId"] = new SelectList(_context.Players, "Id", "Email", team.CaptainId);
            return(View(team));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,NickName,Email,PhoneNumber,FirstName,LastName,Level,TeamId")] Player player)
        {
            if (id != player.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(player);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerExists(player.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Teams, "Id", "TeamName", player.TeamId);
            return(View(player));
        }