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

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

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