public ActionResult SelectAppointmentDate(int id) { var patient = _patientRepository.GetPatient(id); if (patient != null) { var model = new SelectAppointmentDateViewModel { PatientId = patient.Id, FirstName = patient.FirstName, LastName = patient.LastName, DateOfBirth = patient.DateOfBirth, PhoneNumber = patient.PhoneNumber }; return(View(model)); } return(HttpNotFound()); }
public ActionResult SelectAppointmentDate(SelectAppointmentDateViewModel model) { if (ModelState.IsValid) { var day = model.Date.DayOfWeek.ToString(); var enumDay = (WeekDays)Enum.Parse(typeof(WeekDays), day); // check if clinic is open on the date var clinicIsOpen = _clinicRepository .CheckDayExists(enumDay); if (clinicIsOpen) { return(RedirectToAction("AvailableAppointments", new { id = model.PatientId, date = model.Date })); } else { ModelState.AddModelError("Date", $"Clinic is not open on {model.Date.DayOfWeek}"); return(View(model)); } } return(View(model)); }