public List <AppointmentView> GetAppointmentsByPractitionerId(int id)
        {
            lock (_lockingObject)
            {
                List <AppointmentView> appointments = new List <AppointmentView>();
                foreach (Appointment appointment in _appointments)
                {
                    foreach (User person in appointment.Participants)
                    {
                        if (person.Id == id)
                        {
                            List <UserView> userViews = new List <UserView>();
                            foreach (User user in appointment.Participants)
                            {
                                UserView view = new UserView(user.Id, user.Name, user.PhoneNumber, user.Address, user.Email);
                                userViews.Add(view);
                            }
                            RoomView        roomView = new RoomView(appointment.Location.Id, appointment.Location.Name);
                            AppointmentView appView  = new AppointmentView(appointment.Id, appointment.DateAndTime, userViews,
                                                                           new AppointmentTypeView(appointment.AppointmentType.Id, appointment.AppointmentType.Name,
                                                                                                   appointment.AppointmentType.Duration, appointment.AppointmentType.StandardPrice), roomView, appointment.Note, appointment.Price, appointment.NotificationTime, appointment.EmailNotification, appointment.SmsNotification);

                            appointments.Add(appView);
                        }
                    }
                }

                return(appointments);
            }
        }
        public List <UserView> GetClientsFromAppointmentView(AppointmentView appoView)
        {
            List <UserView> users = appoView.Users;

            List <UserView> clients = new List <UserView>();

            foreach (UserView user in users)
            {
                if (_clientRepo.IsClient(user))
                {
                    clients.Add(user);
                }
            }

            return(clients);
        }
        public List <UserView> GetPractitionerFromAppointmentView(AppointmentView appoView)
        {
            List <UserView> users = appoView.Users;

            List <UserView> practitioner = new List <UserView>();

            foreach (UserView user in users)
            {
                if (_practitionerRepo.IsPractitioner(user))
                {
                    practitioner.Add(user);
                }
            }

            return(practitioner);
        }
        public void EditAppointment(AppointmentView appointmentView)
        {
            lock (_lockingObject)
            {
                Appointment appointment     = new Appointment(appointmentView.Id, appointmentView.DateAndTime, appointmentView.Note, appointmentView.NotificationTime, appointmentView.EmailNotification, appointmentView.SMSNotification);
                Appointment tempAppointment = _appointments.Find(appointmentOne => appointmentOne.Id == appointmentView.Id);

                tempAppointment.DateAndTime       = appointmentView.DateAndTime;
                tempAppointment.Note              = appointmentView.Note;
                tempAppointment.EmailNotification = appointment.EmailNotification;
                tempAppointment.SmsNotification   = appointment.SmsNotification;
                tempAppointment.NotificationTime  = appointment.NotificationTime;

                _updateAppointmentNotification.AppointmentUpdatedNotification(tempAppointment);

                _persistable.EditAppointment(tempAppointment);
                AppointmentsChangedEventHandler?.Invoke(appointment, EventArgs.Empty);
            }
        }
        public AppointmentView GetAppointmentById(int appointmentId)
        {
            lock (_lockingObject)
            {
                Appointment     appointment = _appointments.Find(app => app.Id == appointmentId);
                List <UserView> userViews   = new List <UserView>();

                foreach (User user in appointment.Participants)
                {
                    UserView view = new UserView(user.Id, user.Name, user.PhoneNumber, user.Address, user.Email);
                    userViews.Add(view);
                }

                AppointmentTypeView typeView        = new AppointmentTypeView(appointment.AppointmentType.Id, appointment.AppointmentType.Name, appointment.AppointmentType.Duration, appointment.AppointmentType.StandardPrice);
                RoomView            roomView        = new RoomView(appointment.Location.Id, appointment.Location.Name);
                AppointmentView     appointmentView = new AppointmentView(appointment.Id, appointment.DateAndTime, userViews, typeView, roomView, appointment.Note, appointment.Price, appointment.NotificationTime, appointment.EmailNotification, appointment.SmsNotification);

                return(appointmentView);
            }
        }
 public void EditAppointment(AppointmentView appointmentView)
 {
     _appointmentRepo.EditAppointment(appointmentView);
 }