public async Task <IActionResult> Edit(int id, [Bind("Id,IdTypeCarte,Code")] CarteIdentite carteIdentite) { if (id != carteIdentite.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(carteIdentite); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarteIdentiteExists(carteIdentite.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdTypeCarte"] = new SelectList(_context.TypeCarte, "Id", "Id", carteIdentite.IdTypeCarte); return(View(carteIdentite)); }
public async Task <IActionResult> Create([Bind("Id,IdTypeCarte,Code")] CarteIdentite carteIdentite) { if (ModelState.IsValid) { _context.Add(carteIdentite); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdTypeCarte"] = new SelectList(_context.TypeCarte, "Id", "Id", carteIdentite.IdTypeCarte); return(View(carteIdentite)); }