Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Events,HockeyDay,DayInLife,Hours,NumberOfGames,GameId,GameId1,GameId2")] Hockey4LifeLog hockey4LifeLog)
        {
            if (id != hockey4LifeLog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hockey4LifeLog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Hockey4LifeLogExists(hockey4LifeLog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(ListHockey4LifeLogs2020)));
            }
            ViewData["GameId"]  = new SelectList(_context.Game, "Id", "GameNumber", hockey4LifeLog.GameId);
            ViewData["GameId1"] = new SelectList(_context.Game, "Id", "GameNumber", hockey4LifeLog.GameId1);
            ViewData["GameId2"] = new SelectList(_context.Game, "Id", "GameNumber", hockey4LifeLog.GameId2);
            return(View(hockey4LifeLog));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,Date,Events,HockeyDay,DayInLife,Hours,NumberOfGames,GameId,GameId1,GameId2")] Hockey4LifeLog hockey4LifeLog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hockey4LifeLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ListHockey4LifeLogs2020)));
            }
            ViewData["GameId"]  = new SelectList(_context.Game, "Id", "GameNumber", hockey4LifeLog.GameId);
            ViewData["GameId1"] = new SelectList(_context.Game, "Id", "GameNumber", hockey4LifeLog.GameId1);
            ViewData["GameId2"] = new SelectList(_context.Game, "Id", "GameNumber", hockey4LifeLog.GameId2);
            return(View(hockey4LifeLog));
        }