public async Task <IActionResult> OnPostAsync() { TodaysAppointments = await _context.Appointment.Where(m => m.AppointmentDate == DayTracker.Today).ToListAsync(); foreach (Appointment apt in TodaysAppointments) { // arrived if (arrivalCheckBoxes.Contains(apt.AppointmentID)) { apt.hasArrived = true; } else { apt.hasArrived = false; } // checked in if (checkedinCheckBoxes.Contains(apt.AppointmentID)) { apt.hasBeenCheckedIn = true; } else { apt.hasBeenCheckedIn = false; } if (withDoctorCheckBoxes.Contains(apt.AppointmentID)) { apt.isWithDoctor = true; } else { apt.isWithDoctor = false; } if (finishedCheckBoxes.Contains(apt.AppointmentID)) { apt.isFinished = true; } else { apt.isFinished = false; } //update db _context.Attach(apt).State = EntityState.Modified; } await _context.SaveChangesAsync(); return(RedirectToPage("/frontdesk/Today/PatientFlow")); }
public async Task <IActionResult> OnPostAsync() { //if (!ModelState.IsValid) //{ // AvailablePatients = await _context.Patient.ToListAsync(); // return Page(); //} //var entry = _context.Add(new Appointment()); //entry.CurrentValues.SetValues(Appointment); Appointment.PatientID = idOfSelectedPatient; _context.Appointment.Add(Appointment); SelectedPatient = await _context.Patient.FirstOrDefaultAsync(m => m.ID == idOfSelectedPatient); // assign the patient a time slot of 0 if you want to say they don't have an appointment today if (selectedTimeSlot == 0) { SelectedPatient.hasAppointmentToday = false; } // any other number assumes that they do else { SelectedPatient.hasAppointmentToday = true; } // assign them the selected time slot SelectedPatient.appointmentTimeSlot = selectedTimeSlot; // update the database _context.Attach(SelectedPatient).State = EntityState.Modified; // save it await _context.SaveChangesAsync(); // goes back to page for Today return(RedirectToPage("/frontdesk/Today/PatientFlow")); }