public IActionResult OnPost() { if (!ModelState.IsValid) { Doctors = new SelectList(appointmentData.GetDoctors().Select(d => d.DoctorName)); Locations = new SelectList(appointmentData.GetLocations().Select(l => l.LocationName)); return(Page()); } if (Appointment.AppointmentId > 0) { appointmentData.Update(Appointment); } else { appointmentData.Add(Appointment); } appointmentData.Commit(); TempData["Message"] = "Appointment Saved!"; return(RedirectToPage("./Detail", new { appointmentId = Appointment.AppointmentId })); }