public async Task <IActionResult> Edit(int id, [Bind("NomP,PrenomP,Genre,NumAS,DateNaiss,DateC,IdDocteur,Id")] Dossierpatient dossierpatient) { if (id != dossierpatient.Id) { return(NotFound()); } if (ModelState.IsValid) { try { CliniqueDbContext context = _contextFactory.CreateDbContext(); context.Update(dossierpatient); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DossierpatientExists(dossierpatient.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Genre"] = new SelectList(Enum.GetNames(typeof(Genre))); ViewData["IdDocteur"] = new SelectList(_contextFactory.CreateDbContext().Docteurs, "Id", "NomM", dossierpatient.IdDocteur); return(View(dossierpatient)); }
public async Task <IActionResult> Create([Bind("NomP,PrenomP,Genre,NumAS,DateNaiss,DateC,IdDocteur,Id")] Dossierpatient dossierpatient) { if (ModelState.IsValid) { CliniqueDbContext context = _contextFactory.CreateDbContext(); context.Add(dossierpatient); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Genre"] = new SelectList(Enum.GetNames(typeof(Genre))); ViewData["IdDocteur"] = new SelectList(_contextFactory.CreateDbContext().Docteurs, "Id", "NomM", dossierpatient.IdDocteur); return(View(dossierpatient)); }