public IActionResult OnPost() { if (ModelState.IsValid) { var patient = patientData.GetPatientById(Appointment.PatientId); Appointment.Patient = patient; if (Appointment.Id == 0) { Appointment = appointmentData.Create(Appointment); TempData["TempMessage"] = "New appointment created!"; } else { Appointment = appointmentData.Update(Appointment); TempData["TempMessage"] = "Appointment is updated!"; } appointmentData.Commit(); return(RedirectToPage("./List")); } var patients = patientData.GetPatients().ToList().Select(p => new { Id = p.Id, Display = $"{p.FirstName} {p.LastName}" }); Patients = new SelectList(patients, "Id", "Display"); Symptom = htmlHelper.GetEnumSelectList <Symptom>(); return(Page()); }
public IActionResult CreateAppointment(AppointmentDto appointmentDto) { if (appointmentDto == null) { return(BadRequest()); } var appointment = new Appointment(); appointment.Date = appointmentDto.Date; appointment.HasMedicalHistory = appointmentDto.HasMedicalHistory; appointment.IsCoronaPositive = appointmentDto.IsCoronaPositive; appointment.IsDead = appointmentDto.IsDead; appointment.IsForSelfIsolation = appointmentDto.IsForSelfIsolation; appointment.IsRecovered = appointmentDto.IsRecovered; appointment.IsTested = appointmentDto.IsTested; appointment.PatientId = appointmentDto.PatientId; appointmentData.Create(appointment); appointmentData.Commit(); return(CreatedAtRoute("GetAppointment", new { id = appointment.Id }, appointment)); }