public IActionResult Delete(int id) { VerifiedPatient vp = _verificationContext.VerifiedPatients.FirstOrDefault(p => p.Id == id); _verificationContext.Remove(vp); _verificationContext.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public IActionResult Verify(int id) { Prescription prescription = _prescriptionContext.Prescriptions.First(p => p.Id == id); VerifiedPatient patient = _verificationContext.VerifiedPatients.FirstOrDefault(p => p.Name == prescription.PatientName && p.Address == prescription.PatientAddress && p.DateOfBirth == prescription.PatientDOB); prescription.PatientVerified = patient != null; _prescriptionContext.Prescriptions.Update(prescription); _prescriptionContext.SaveChanges(); return(RedirectToAction("Details", "Prescriptions", new { id = prescription.Id })); }
public async Task <IActionResult> Create(VerifiedPatient vp) { HttpContext.Session.SetString(HomeController.CreatePatientNameValidation, ""); HttpContext.Session.SetString(HomeController.CreatePatientAddressValidation, ""); HttpContext.Session.SetString(HomeController.CreatePatientPronounsValidation, ""); HttpContext.Session.SetString(HomeController.CreatePatientDOBValidation, ""); if (string.IsNullOrEmpty(vp.Name)) { HttpContext.Session.SetString(HomeController.CreatePatientNameValidation, "Required Field"); return(View(vp)); } if (vp.DateOfBirth == DateTime.MinValue) { HttpContext.Session.SetString(HomeController.CreatePatientDOBValidation, "Required Field"); return(View(vp)); } if (string.IsNullOrEmpty(vp.Pronouns)) { HttpContext.Session.SetString(HomeController.CreatePatientPronounsValidation, "Required Field"); return(View(vp)); } if (string.IsNullOrEmpty(vp.Address)) { HttpContext.Session.SetString(HomeController.CreatePatientAddressValidation, "Required Field"); return(View(vp)); } DateTime currentYear = new DateTime(DateTime.Now.Year, 1, 1); if (vp.DateOfBirth >= currentYear) { HttpContext.Session.SetString(HomeController.CreatePatientDOBValidation, "Policyholder cannot be born in this year"); return(View(vp)); } _verificationContext.Add(vp); await _verificationContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public IActionResult Create() { VerifiedPatient vp = new VerifiedPatient(); return(View(vp)); }