コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Key,NumberOfAccountsAvailable")] ProfessorKey professorKey)
        {
            if (id != professorKey.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(professorKey);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProfessorKeyExists(professorKey.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(professorKey));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Key,NumberOfAccountsAvailable")] ProfessorKey professorKey)
        {
            if (ModelState.IsValid)
            {
                _context.Add(professorKey);
                await _context.SaveChangesAsync();

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