public async Task <IActionResult> Edit(int id, [Bind("Id,ContratId,MaterielId,Lieu,UserId")] LocationMateriel locationMateriel) { if (id != locationMateriel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(locationMateriel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationMaterielExists(locationMateriel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ContratId"] = new SelectList(_context.Contrat, "Id", "Id", locationMateriel.ContratId); ViewData["MaterielId"] = new SelectList(_context.Materiel, "Id", "Id", locationMateriel.MaterielId); return(View(locationMateriel)); }
public async Task <IActionResult> Create([Bind("Id,ContratId,MaterielId,Lieu,UserId")] LocationMateriel locationMateriel) { if (ModelState.IsValid) { _context.Add(locationMateriel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContratId"] = new SelectList(_context.Contrat, "Id", "Id", locationMateriel.ContratId); ViewData["MaterielId"] = new SelectList(_context.Materiel, "Id", "Id", locationMateriel.MaterielId); return(View(locationMateriel)); }