public static List <AppointmentRealocation> CreateLisfOfAppointmentRealocations() { List <AppointmentRealocation> appointments = new List <AppointmentRealocation>(); AppointmentRealocation app1 = new AppointmentRealocation { Id = 4, Period = new Period() { StartTime = new DateTime(2020, 12, 5, 8, 0, 0), EndTime = new DateTime(2020, 12, 5, 8, 30, 0) }, Deleted = false, Finished = true, RoomId = 1003, HospitalEquipmentId = 1 }; AppointmentRealocation app2 = new AppointmentRealocation { Id = 6, Period = new Period() { StartTime = new DateTime(2020, 12, 5, 8, 0, 0), EndTime = new DateTime(2020, 12, 5, 8, 30, 0) }, Deleted = false, Finished = true, RoomId = 1003, HospitalEquipmentId = 1 }; appointments.Add(app1); appointments.Add(app2); return(appointments); }
private bool CheckForMatchingAppointments(AppointmentRealocation appointment, List <AppointmentRealocation> appointmentRealocationsToRoom) { foreach (AppointmentRealocation appointmentTo in appointmentRealocationsToRoom) { if (appointment.Period.StartTime == appointmentTo.Period.StartTime) { return(true); } } return(false); }
public bool CheckIsRoomAvailableInSelectedTime(int roomId, DateTime chosenDateTime) { AppointmentRealocation appointmentRealocation = _appointmentRealocationRepository.GetAll().ToList().Find(a => a.RoomId == roomId && a.Period.StartTime == chosenDateTime); if (appointmentRealocation == null) { return(true && !AppointmentIsScheduledAlready(roomId, chosenDateTime)); } else { return(false); } }
public static AppointmentRealocation CreateAppointmentRealocation() { AppointmentRealocation app = new AppointmentRealocation { Id = 4, Period = new Period() { StartTime = new DateTime(2020, 12, 5, 8, 0, 0), EndTime = new DateTime(2020, 12, 5, 8, 30, 0) }, Deleted = false, Finished = true, RoomId = 1003, HospitalEquipmentId = 1 }; return(app); }
private List <AppointmentRealocation> GetAvailableBy(int roomId, DateTime date) { if (AppointmentIsScheduledAlready(roomId, date)) { return(new List <AppointmentRealocation>()); } List <AppointmentRealocation> occupied = GetByRoomAndDate(roomId, date); List <AppointmentRealocation> allAppointments = InitializeAppointments(roomId, date); List <AppointmentRealocation> available = new List <AppointmentRealocation>(allAppointments); foreach (AppointmentRealocation appointmentIt in allAppointments) { AppointmentRealocation appointment = occupied.FirstOrDefault(a => a.isOccupied(appointmentIt.Period)); if (appointment != null) { available.Remove(appointmentIt); } } return(available); }
private List <AppointmentRealocation> InitializeAppointments(int roomId, DateTime date) { List <AppointmentRealocation> appointments = new List <AppointmentRealocation>(); DateTime appointmentStart = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); DateTime appointmentEnd = appointmentStart.AddDays(1); for (DateTime start = appointmentStart; start < appointmentEnd; start = start.AddMinutes(appointmentDuration)) { if (start >= DateTime.Now) { AppointmentRealocation appointment = new AppointmentRealocation { RoomId = roomId, Period = new Period() { StartTime = start, EndTime = start.AddMinutes(appointmentDuration) } }; appointments.Add(appointment); } } return(appointments); }
private async void ButtonScheduleAppointment(object sender, RoutedEventArgs e) { AppointmentRealocation appointmentRealocation = (AppointmentRealocation)dataGridAppointments.SelectedItem; if (appointmentRealocation == null) { MessageBox.Show("You didn't select appointment for realocation!"); return; } appointmentRealocation.RoomId = FromRoomId; AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation, appointmentRealocation = appointmentRealocation }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); appointmentRealocation.RoomId = ToRoomId; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); MessageBox.Show("Appointment for realocation is succesfully scheduled!"); page.MainFrame.Content = new ScheduleEquipmentRealocation(page); }
public AppointmentRealocation UpdateAppointement(AppointmentRealocation appointmentRealocation) { return(_appointmentRealocationRepository.Update(appointmentRealocation)); }
public AppointmentRealocation ScheduleAppointmentRealocation(AppointmentRealocation appointmentRealocation) { return(_appointmentRealocationRepository.Create(appointmentRealocation)); }