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 })); }