public async Task <IActionResult> Edit(int id, Seraphin seraphin) { if (id != seraphin.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(seraphin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeraphinExists(seraphin.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(seraphin)); }
// GET: Seraphins/Create public IActionResult Create(int id) { Seraphin seraphin = new Seraphin(); seraphin.IdStation = id; return(View(seraphin)); }
public async Task <IActionResult> Create(Seraphin seraphin) { if (ModelState.IsValid) { seraphin.Station = _context.Stations.Find(seraphin.IdStation); seraphin.Id = 0; _context.Add(seraphin); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(seraphin)); }