private AppointmentRenovation AppointmentRealocationForSeparating(AppointmentRenovation appointmentRealocation)
 {
     appointmentRealocation.AppointmentRealocationType = AppointmentRealocationType.RenovationSeparating;
     appointmentRealocation.Description  = scheduleRenovation.textBoxDescription.Text.Trim();
     appointmentRealocation.RoomOneType  = (RoomType)scheduleRenovation.comboBoxRoomTypeMergingRoom1.SelectedIndex;
     appointmentRealocation.RoomOneUse   = scheduleRenovation.textBoxRoom1Use.Text.Trim();
     appointmentRealocation.RoomOneLabel = scheduleRenovation.room.RoomLabel + ".1";
     appointmentRealocation.RoomTwoType  = (RoomType)scheduleRenovation.comboBoxRoomTypeMergingRoom2.SelectedIndex;
     appointmentRealocation.RoomTwoUse   = scheduleRenovation.textBoxRoom2Use.Text.Trim();
     appointmentRealocation.RoomTwoLabel = scheduleRenovation.room.RoomLabel + ".2";
     return(appointmentRealocation);
 }
 private AppointmentRenovation AppointmentRealocationForMerging(AppointmentRenovation appointmentRealocation)
 {
     appointmentRealocation.AppointmentRealocationType = AppointmentRealocationType.RenovationMerging;
     appointmentRealocation.Description  = scheduleRenovation.textBoxDescription.Text.Trim();
     appointmentRealocation.RoomOneType  = (RoomType)scheduleRenovation.comboBoxRoomType.SelectedIndex;
     appointmentRealocation.RoomOneUse   = scheduleRenovation.textBoxRoomUse.Text.Trim();
     appointmentRealocation.RoomOneLabel = scheduleRenovation.room.RoomLabel;
     appointmentRealocation.RoomTwoType  = ((Room)scheduleRenovation.dataGridRoom.SelectedItem).RoomType;
     appointmentRealocation.RoomTwoUse   = ((Room)scheduleRenovation.dataGridRoom.SelectedItem).RoomUse;
     appointmentRealocation.RoomTwoLabel = ((Room)scheduleRenovation.dataGridRoom.SelectedItem).RoomLabel;
     return(appointmentRealocation);
 }
 private AppointmentRenovation AppointmentRealocationForMaintenance(AppointmentRenovation appointmentRealocation)
 {
     appointmentRealocation.AppointmentRealocationType = AppointmentRealocationType.RenovationMaintenance;
     appointmentRealocation.Description  = scheduleRenovation.textBoxDescription.Text.Trim();
     appointmentRealocation.RoomOneType  = scheduleRenovation.room.RoomType;
     appointmentRealocation.RoomOneUse   = scheduleRenovation.room.RoomUse;
     appointmentRealocation.RoomOneLabel = scheduleRenovation.room.RoomLabel;
     appointmentRealocation.RoomTwoType  = scheduleRenovation.room.RoomType;
     appointmentRealocation.RoomTwoUse   = scheduleRenovation.room.RoomUse;
     appointmentRealocation.RoomTwoLabel = scheduleRenovation.room.RoomLabel;
     return(appointmentRealocation);
 }
예제 #4
0
        public static AppointmentRenovation CreateAppointmentRenovation()
        {
            AppointmentRenovation app = new AppointmentRenovation
            {
                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,
            };

            return(app);
        }
        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();
        }
        private List <AppointmentRenovation> GetAvailableBy(int roomId, DateTime date)
        {
            if (AppointmentIsScheduledAlready(roomId, date))
            {
                return(new List <AppointmentRenovation>());
            }
            List <AppointmentRenovation> occupied        = GetByRoomAndDate(roomId, date);
            List <AppointmentRenovation> allAppointments = InitializeAppointments(roomId, date);
            List <AppointmentRenovation> available       = new List <AppointmentRenovation>(allAppointments);

            foreach (AppointmentRenovation appointmentIt in allAppointments)
            {
                AppointmentRenovation appointment = occupied.FirstOrDefault(a => a.isOccupied(appointmentIt.Period));
                if (appointment != null)
                {
                    available.Remove(appointmentIt);
                }
            }
            return(available);
        }
        private List <AppointmentRenovation> InitializeAppointments(int roomId, DateTime date)
        {
            List <AppointmentRenovation> appointments = new List <AppointmentRenovation>();
            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)
                {
                    AppointmentRenovation appointment = new AppointmentRenovation
                    {
                        RoomId = roomId,
                        Period = new Period()
                        {
                            StartTime = start, EndTime = start.AddMinutes(appointmentDuration)
                        }
                    };
                    appointments.Add(appointment);
                }
            }
            return(appointments);
        }
 public AppointmentRenovation UpdateAppointement(AppointmentRenovation appointmentRenovation)
 {
     return(_AppointmentRenovationRepository.Update(appointmentRenovation));
 }
 public AppointmentRenovation ScheduleAppointmentRenovation(AppointmentRenovation appointmentRenovation)
 {
     return(_AppointmentRenovationRepository.Create(appointmentRenovation));
 }