public IActionResult Post(AppointmentRealocationDTO appointmentRealocationDTO) { if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.ByRoomAndDateTime) { return(Ok(_appointmentRealocationService.GetAllAvailableAppointmentByRoomAndDateTime(appointmentRealocationDTO.RoomId, appointmentRealocationDTO.StartInterval, appointmentRealocationDTO.EndInterval))); } else if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.CheckIsRoomAvailable) { return(Ok(_appointmentRealocationService.CheckIsRoomAvailableInSelectedTime(appointmentRealocationDTO.RoomId, appointmentRealocationDTO.StartInterval))); } else if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation) { return(Ok(_appointmentRealocationService.ScheduleAppointmentRealocation(appointmentRealocationDTO.appointmentRealocation))); } else if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.AlternativeAppointments) { return(Ok(_appointmentRealocationService.GetAlternativeAvailableAppointments(appointmentRealocationDTO.FromRoomId, appointmentRealocationDTO.ToRoomId, appointmentRealocationDTO.StartInterval, appointmentRealocationDTO.HospitalEquipmentId))); } else if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.UpdateRealocation) { return(Ok(_appointmentRealocationService.UpdateAppointement(appointmentRealocationDTO.appointmentRealocation))); } else { return(Ok()); } }
private async void SearchForAvailableAppointments() { Tuple <DateTime, DateTime> time = ParseDateAndTime(); DateTime beginningTime = time.Item1; DateTime endTime = time.Item2; AppointmentRealocationDTO appointmentRealocationDTO; if (scheduleRenovation.comboBoxRenovationType.SelectedIndex == 1) { Room room = (Room)scheduleRenovation.dataGridRoom.SelectedItem; appointmentRealocationDTO = new AppointmentRealocationDTO() { FromRoomId = scheduleRenovation.room.Id, ToRoomId = room.Id, appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.ByTwoRooms, StartInterval = beginningTime, EndInterval = endTime }; } else { appointmentRealocationDTO = new AppointmentRealocationDTO() { RoomId = scheduleRenovation.room.Id, appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.ByRoomAndDateTime, StartInterval = beginningTime, EndInterval = endTime } }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); }
private async Task HttpRequestToAppointmentRealocationController(AppointmentRealocationDTO appointmentRealocationDTO) { string jsonSearchAppointmentsDTO = JsonConvert.SerializeObject(appointmentRealocationDTO); HttpClient client = new HttpClient(); var content = new StringContent(jsonSearchAppointmentsDTO, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("http://localhost:8083/api/appointmentforroommanipulation/", content); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); }
private async Task GetHospitalEquipmentId(int equipmentTypeId) { AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { RoomId = FromRoomId, EquipmentTypeId = EquipmentTypeId }; await HttpRequestToHospitalEquipmentController(appointmentRealocationDTO); }
public IActionResult Post(AppointmentRealocationDTO appointmentRealocationDTO) { if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.UpdateRealocation) { return(Ok(_appointmentForRoomManipulationService.Update(appointmentRealocationDTO.appointmentForRoomManipulation))); } else { return(Ok()); } }
private async Task HttpRequestToHospitalEquipmentController(AppointmentRealocationDTO appointmentRealocationDTO) { string jsonSearchAppointmentsDTO = JsonConvert.SerializeObject(appointmentRealocationDTO); HttpClient client = new HttpClient(); var content = new StringContent(jsonSearchAppointmentsDTO, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("http://localhost:60304/api/hospitalequipment/", content); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); hospitalEquipment = (JsonConvert.DeserializeObject <HospitalEquipment>(responseBody)); }
private async void SearchDataBaseForSuggestions() { await GetHospitalEquipmentId(EquipmentTypeId); AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.AlternativeAppointments, FromRoomId = FromRoomId, ToRoomId = ToRoomId, StartInterval = DateTime, HospitalEquipmentId = hospitalEquipment.Id }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); }
private async Task HttpRequestToAppointmentRealocationController(AppointmentRealocationDTO appointmentRealocationDTO) { string jsonSearchAppointmentsDTO = JsonConvert.SerializeObject(appointmentRealocationDTO); HttpClient client = new HttpClient(); var content = new StringContent(jsonSearchAppointmentsDTO, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("http://localhost:8083/api/appointmentrealocation/", content); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.CheckIsRoomAvailable) { bool isRoomAvailable = (JsonConvert.DeserializeObject <bool>(responseBody)); roomAvailability = isRoomAvailable; } }
private async Task HttpRequestToAppointmentRealocationController(AppointmentRealocationDTO appointmentRealocationDTO) { string jsonSearchAppointmentsDTO = JsonConvert.SerializeObject(appointmentRealocationDTO); HttpClient client = new HttpClient(); var content = new StringContent(jsonSearchAppointmentsDTO, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("http://localhost:8083/api/appointmentrealocation/", content); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule != AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation) { appointmentRealocations = new List <AppointmentRealocation>(JsonConvert.DeserializeObject <List <AppointmentRealocation> >(responseBody)); dataGridAppointments.ItemsSource = appointmentRealocations; } }
private async void ButtonCancelAppointmentRealocation(object sender, RoutedEventArgs e) { AppointmentForRoomManipulation appointmentRealocation = (AppointmentForRoomManipulation)dataGridAppointmentRealocation.SelectedItem; if (appointmentRealocation == null) { MessageBox.Show("You didn't select any realocation appointment!"); return; } appointmentRealocation.IsCanceled = true; AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.UpdateRealocation, appointmentForRoomManipulation = appointmentRealocation }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); appointmentRealocations.Remove(appointmentRealocation); }
private async void ButtonSchedule(object sender, RoutedEventArgs e) { AppointmentRenovation appointmentRealocation = (AppointmentRenovation)dataGridAppointment.SelectedItem; if (appointmentRealocation == null) { MessageBox.Show("You didn't select any appointment for renovation!"); return; } if (scheduleRenovation.comboBoxRenovationType.SelectedIndex == 0) { appointmentRealocation = AppointmentRealocationForMaintenance(appointmentRealocation); AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { appointmentRenovation = appointmentRealocation, appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); } else if (scheduleRenovation.comboBoxRenovationType.SelectedIndex == 1) { appointmentRealocation = AppointmentRealocationForMerging(appointmentRealocation); AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { appointmentRenovation = appointmentRealocation, appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); appointmentRealocationDTO.appointmentRenovation.RoomId = scheduleRenovation.room.Id; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); } else { appointmentRealocation = AppointmentRealocationForSeparating(appointmentRealocation); AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { appointmentRenovation = appointmentRealocation, appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); } MessageBox.Show("Renovation is successfuly scheduled!"); this.Close(); }
public IActionResult Post(AppointmentRealocationDTO appointmentRealocationDTO) { if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.ByRoomAndDateTime) { return(Ok(_appointmentRenovationService.GetAllAvailableAppointmentByRoomAndDateTime(appointmentRealocationDTO.RoomId, appointmentRealocationDTO.StartInterval, appointmentRealocationDTO.EndInterval))); } else if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation) { return(Ok(_appointmentRenovationService.ScheduleAppointmentRenovation(appointmentRealocationDTO.appointmentRenovation))); } else if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.UpdateRealocation) { return(Ok(_appointmentRenovationService.UpdateAppointement(appointmentRealocationDTO.appointmentRenovation))); } else if (appointmentRealocationDTO.appointmentRealocationSearchOrSchedule == AppointmentRealocationSearchOrSchedule.ByTwoRooms) { return(Ok(_appointmentRenovationService.GetAvailableAppointmentRenovationsForTwoRoms(appointmentRealocationDTO.FromRoomId, appointmentRealocationDTO.ToRoomId, appointmentRealocationDTO.StartInterval, appointmentRealocationDTO.EndInterval))); } else { return(Ok()); } }
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); }
private async void ButtonScheduleRealocation(object sender, RoutedEventArgs e) { Room fromRoom = (Room)dataGridFrom.SelectedItem; Room toRoom = (Room)dataGridTo.SelectedItem; EquipmentType equipmentType = (EquipmentType)comboBoxEquipment.SelectedItem; if (fromRoom == null || toRoom == null) { MessageBox.Show("You didn't select initial room or destination room!"); return; } if (fromRoom.Id == toRoom.Id) { MessageBox.Show("You selected the same rooms!"); return; } DateTime dateTime; if (!DateTime.TryParseExact(textBoxFrom.Text, "dd.MM.yyyy - HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) { MessageBox.Show("Date and time are not valid!"); return; } if (dateTime < DateTime.Now) { MessageBox.Show("Date and time are not valid!"); return; } AppointmentRealocationDTO appointmentRealocationDTO = new AppointmentRealocationDTO() { appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.CheckIsRoomAvailable, RoomId = fromRoom.Id, StartInterval = dateTime }; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); if (!roomAvailability) { ShowOnMap(fromRoom); MessageBox.Show("[FROM] Room with label " + fromRoom.RoomLabel + " and ID=" + fromRoom.Id + " isn't available at selected time!\nProgram will try to calculate best options for you..."); await HttpRequestToHospitalEquipmentController(appointmentRealocationDTO); page.MainFrame.Content = new ScheduleEquipmentRealocationIfRoomIsntEmpty(page, this, fromRoom.Id, toRoom.Id, equipmentType.Id, dateTime); return; } appointmentRealocationDTO.RoomId = toRoom.Id; await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); if (!roomAvailability) { ShowOnMap(toRoom); MessageBox.Show("[TO] Room with label " + toRoom.RoomLabel + " and ID=" + toRoom.Id + " isn't available at selected time!\nProgram will try to calculate best options for you..."); await HttpRequestToHospitalEquipmentController(appointmentRealocationDTO); page.MainFrame.Content = new ScheduleEquipmentRealocationIfRoomIsntEmpty(page, this, fromRoom.Id, toRoom.Id, equipmentType.Id, dateTime); return; } appointmentRealocationDTO.appointmentRealocationSearchOrSchedule = AppointmentRealocationSearchOrSchedule.ScheduleRealocationOrRenovation; appointmentRealocationDTO.RoomId = fromRoom.Id; appointmentRealocationDTO.EquipmentTypeId = equipmentType.Id; await HttpRequestToHospitalEquipmentController(appointmentRealocationDTO); appointmentRealocationDTO.appointmentRealocation = CreateRealocation(fromRoom.Id, dateTime, hospitalEquipment.Id); await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); appointmentRealocationDTO.appointmentRealocation = CreateRealocation(toRoom.Id, dateTime, hospitalEquipment.Id); await HttpRequestToAppointmentRealocationController(appointmentRealocationDTO); MessageBox.Show("Appointment for realocation is succesfully scheduled!"); }