public async Task <IActionResult> Create(Paziente paziente) { try { if (ModelState.IsValid) { _context.Add(paziente); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(paziente)); }
public async Task <IActionResult> Create(Esame model) { try { if (ModelState.IsValid) { _context.Add(model); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Consulti", new { id = model.ConsultoId })); } } catch (DbUpdateException ex) { _logger.LogError(ex, "Esame creation failed"); ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(model)); }
public async Task <IActionResult> Create(AnamnesiRemota anamnesi) { try { if (ModelState.IsValid) { _context.Add(anamnesi); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Pazienti", new { id = anamnesi.PazienteId })); } } catch (DbUpdateException ex) { _logger.LogError(ex, "AnamnesiRemota creation failed"); ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(anamnesi)); }