public async Task <IActionResult> Edit(int id, [Bind("Id,Descr,Date,RadicalOrganizationId,RiskyLevelId,CyberThreatTypeId,CountrySourceId")] CyberThreat cyberThreat) { if (id != cyberThreat.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cyberThreat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CyberThreatExists(cyberThreat.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CountrySourceId"] = new SelectList(_context.Countries, "Id", "Id", cyberThreat.CountrySourceId); ViewData["CyberThreatTypeId"] = new SelectList(_context.CyberThreatTypes, "Id", "Id", cyberThreat.CyberThreatTypeId); ViewData["RadicalOrganizationId"] = new SelectList(_context.RadicalOrganizations, "Id", "Id", cyberThreat.RadicalOrganizationId); ViewData["RiskyLevelId"] = new SelectList(_context.RiskyLevels, "Id", "Id", cyberThreat.RiskyLevelId); return(View(cyberThreat)); }
public async Task <IActionResult> Create([Bind("Id,Descr,Date,RadicalOrganizationId,RiskyLevelId,CyberThreatTypeId,CountrySourceId")] CyberThreat cyberThreat) { if (ModelState.IsValid) { _context.Add(cyberThreat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CountrySourceId"] = new SelectList(_context.Countries, "Id", "Id", cyberThreat.CountrySourceId); ViewData["CyberThreatTypeId"] = new SelectList(_context.CyberThreatTypes, "Id", "Id", cyberThreat.CyberThreatTypeId); ViewData["RadicalOrganizationId"] = new SelectList(_context.RadicalOrganizations, "Id", "Id", cyberThreat.RadicalOrganizationId); ViewData["RiskyLevelId"] = new SelectList(_context.RiskyLevels, "Id", "Id", cyberThreat.RiskyLevelId); return(View(cyberThreat)); }