Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("LevelId,Position")] Level level)
        {
            if (id != level.LevelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(level);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LevelExists(level.LevelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(level));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("MenteeId,LevelId,MenteeName,Age")] Mentee mentee)
        {
            if (id != mentee.MenteeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mentee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MenteeExists(mentee.MenteeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LevelId"] = new SelectList(_context.Set <Level>(), "LevelId", "LevelId", mentee.LevelId);
            return(View(mentee));
        }