public async Task <IActionResult> Create(PatientExaminationViewModel patientExamVM) { try { if (ModelState.IsValid) { int id = await PatientsHelper.AddPatientExAsync(patientExamVM); await AppDataHelper.CheckReagentsStockAsync(_context); if (!Request.Cookies.ContainsKey("reagentAlert")) { Response.Cookies.Append("reagentAlert", "true", new CookieOptions { Expires = DateTime.Now.AddMinutes(10) }); } return(RedirectToAction(nameof(Details), new { id = id })); } } catch (DbUpdateException) { //Log the error ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(RedirectToAction(nameof(Create), new { id = patientExamVM.PatientID })); }
public async Task <IActionResult> Index() { await AppDataHelper.CheckReagentsStockAsync(_context); if (!Request.Cookies.ContainsKey("reagentAlert")) { Response.Cookies.Append("reagentAlert", "true", new CookieOptions { Expires = DateTime.Now.AddMinutes(10) }); } return(View()); }
public async Task <IActionResult> DeleteConfirmed(int id) { try { await PatientsHelper.CancelPatientExAsync(id); await AppDataHelper.CheckReagentsStockAsync(_context); if (!Request.Cookies.ContainsKey("reagentAlert")) { Response.Cookies.Append("reagentAlert", "true", new CookieOptions { Expires = DateTime.Now.AddMinutes(10) }); } return(RedirectToAction(nameof(Index))); } catch (DbUpdateException) { return(RedirectToAction(nameof(Delete), new { id = id, saveChangesError = true })); } }
public async Task <IActionResult> ConfirmReceived(int id) { try { ReagentHelper.Init(_context); await ReagentHelper.UpdateReagentStockAsync(id); await AppDataHelper.CheckReagentsStockAsync(_context); if (!Request.Cookies.ContainsKey("reagentAlert")) { Response.Cookies.Append("reagentAlert", "true", new CookieOptions { Expires = DateTime.Now.AddMinutes(10) }); } } catch (Exception ex) when(ex is DbUpdateException || ex is DbUpdateConcurrencyException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); } return(RedirectToAction(nameof(Index))); }