public ActionResult Register(Doctor newDoctor) { // Validate doctor data from the transaction if (newDoctor == null) { ViewBag.message = "Error: Invalid Request - please try again"; return(View(new Doctor())); } if (newDoctor.DoctorID == null || newDoctor.DoctorID.Length == 0) { ViewBag.message = "Error: ID is required"; return(View(newDoctor)); } if (newDoctor.Password == null || newDoctor.Password.Length == 0) { ViewBag.message = "Error: Name is required"; return(View(newDoctor)); } // Add the doctor bool result = DoctorManager.AddNewDoctor(newDoctor); if (result) { ViewBag.message = "Doctor is added"; } else { ViewBag.message = "That doctor could not be added"; } Doctor[] doctors = DoctorManager.GetAllDoctors(); return(View("List", doctors)); }