public ActionResult AddPatient(Patient newPatient) { // Validate patient data from the transaction if (newPatient == null) { ViewBag.message = "Error: Invalid Request - please try again"; return(View(new Patient())); } if (newPatient.PatientID == null || newPatient.PatientID.Length == 0) { ViewBag.message = "Error: ID is required"; return(View(newPatient)); } if (newPatient.PatientName == null || newPatient.PatientName.Length == 0) { ViewBag.message = "Error: Name is required"; return(View(newPatient)); } // Add the patient bool result = PatientManager.AddNewPatient(newPatient); if (result) { ViewBag.message = "Patient is added"; } else { ViewBag.message = "That patient could not be added"; } Patient[] patients = PatientManager.GetAllPatients(); return(View("List", patients)); }