public List <IAppointment> GetAppointments(long staffId, DateTime appointmentDate)
        {
            var request = new GetStaffAppointmentsRequest
            {
                // Set Source Credentials
                SourceCredentials = new SourceCredentials
                {
                    SourceName = "apidevhomework",
                    Password   = "******",
                    SiteIDs    = new ArrayOfInt {
                        -31100
                    }
                },
                // Set Staff Credentials
                StaffCredentials = new StaffCredentials
                {
                    Username = @"Owner",
                    Password = @"apidemo1234",
                    SiteIDs  = new ArrayOfInt {
                        -31100
                    }
                },
                // Inquire about this. Instructions say to use staff credentials in the format below, which doesn't yeild any results.
                // Using the owner creds with the StaffIds array does get the results that we are looking for. Bug in API Or User Error?
                // Note to Self: Change first parameter back to IStaff instead of long when this is working as instructions state
                //StaffCredentials = new StaffCredentials
                //    {
                //        Username = string.Format("{0}.{1}", staff.FirstName, staff.LastName),
                //        Password = string.Format("{0}{1}{2}", staff.FirstName[0], staff.LastName[0], staff.Id),
                //        SiteIDs = new ArrayOfInt {-31100}
                //    }
                StaffIDs = new ArrayOfLong {
                    staffId
                },
                StartDate = appointmentDate,
                EndDate   = appointmentDate
            };

            var proxy = new AppointmentServiceSoapClient();
            GetStaffAppointmentsResult response = proxy.GetStaffAppointments(request);

            return(response.Appointments.Select(appointment => new AppointmentModel
            {
                Id = appointment.ID,
                AppointmentDate = appointment.StartDateTime,
                StartTime = appointment.StartDateTime,
                EndTime = appointment.EndDateTime,
                ClientName = string.Format("{0} {1}", appointment.Client.FirstName, appointment.Client.LastName),
                SessionType = appointment.SessionType.Name
            }).Cast <IAppointment>().ToList());
        }
Esempio n. 2
0
        public List <MindBodyDemo.Models.Data.Appointment> GetStaffAppointments(string first, string lastName, string staffId)
        {
            GetStaffAppointmentsRequest request = new GetStaffAppointmentsRequest();

            // for source credentials
            AppointmentService.SourceCredentials sourceCredentials = new AppointmentService.SourceCredentials();
            sourceCredentials.SourceName = "MBO.Hsiang-Ting.Yang";
            sourceCredentials.Password   = "******";
            int[] ids = new int[1];
            ids[0] = -31100;
            sourceCredentials.SiteIDs = ids;

            request.SourceCredentials = sourceCredentials;

            // for user credentials
            AppointmentService.StaffCredentials staffCredentials = new AppointmentService.StaffCredentials();
            staffCredentials.Username = first + "." + lastName;
            staffCredentials.Password = first[0].ToString().ToLower() + lastName[0].ToString().ToLower() + staffId;
            staffCredentials.SiteIDs  = ids;

            request.StaffCredentials = staffCredentials;
            request.StartDate        = new DateTime(2014, 1, 3);
            request.EndDate          = new DateTime(2014, 1, 4);

            MindBodyDemo.AppointmentService.AppointmentService appointmentServ = new AppointmentService.AppointmentService();
            var result = appointmentServ.GetStaffAppointments(request);

            List <MindBodyDemo.Models.Data.Appointment> apps = new List <MindBodyDemo.Models.Data.Appointment>();

            if (result != null && result.Appointments != null)
            {
                foreach (var app in result.Appointments)
                {
                    MindBodyDemo.Models.Data.Appointment data = new Data.Appointment();
                    data.appointmentDate = app.StartDateTime.Value.ToString("yyyy-MM-dd");
                    data.startDate       = app.StartDateTime.Value.TimeOfDay.ToString();
                    data.endDate         = app.EndDateTime.Value.TimeOfDay.ToString();
                    data.appointmentType = app.SessionType.Name;

                    data.clientName = app.Client.FirstName + app.Client.LastName;
                    apps.Add(data);
                }
            }

            return(apps);
        }
        public List<IAppointment> GetAppointments(long staffId, DateTime appointmentDate)
        {
            var request = new GetStaffAppointmentsRequest
                {
                    // Set Source Credentials
                    SourceCredentials = new SourceCredentials
                        {
                            SourceName = "apidevhomework",
                            Password = "******",
                            SiteIDs = new ArrayOfInt {-31100}
                        },
                    // Set Staff Credentials
                    StaffCredentials = new StaffCredentials
                        {
                            Username = @"Owner",
                            Password = @"apidemo1234",
                            SiteIDs = new ArrayOfInt {-31100}
                        },
                    // Inquire about this. Instructions say to use staff credentials in the format below, which doesn't yeild any results.
                    // Using the owner creds with the StaffIds array does get the results that we are looking for. Bug in API Or User Error?
                    // Note to Self: Change first parameter back to IStaff instead of long when this is working as instructions state
                    //StaffCredentials = new StaffCredentials
                    //    {
                    //        Username = string.Format("{0}.{1}", staff.FirstName, staff.LastName),
                    //        Password = string.Format("{0}{1}{2}", staff.FirstName[0], staff.LastName[0], staff.Id),
                    //        SiteIDs = new ArrayOfInt {-31100}
                    //    }
                    StaffIDs = new ArrayOfLong {staffId},
                    StartDate = appointmentDate,
                    EndDate = appointmentDate
                };

            var proxy = new AppointmentServiceSoapClient();
            GetStaffAppointmentsResult response = proxy.GetStaffAppointments(request);

            return response.Appointments.Select(appointment => new AppointmentModel
                {
                    Id = appointment.ID,
                    AppointmentDate = appointment.StartDateTime,
                    StartTime = appointment.StartDateTime,
                    EndTime = appointment.EndDateTime,
                    ClientName = string.Format("{0} {1}", appointment.Client.FirstName, appointment.Client.LastName),
                    SessionType = appointment.SessionType.Name
                }).Cast<IAppointment>().ToList();
        }
        public virtual List <IAppointment> GetStaffAppointments(IStaff staff, DateTime appointmentDate)
        {
            // Appointments might span midnight
            DateTime endDate = appointmentDate.AddDays(1);

            var request = new GetStaffAppointmentsRequest
            {
                SourceCredentials = new SourceCredentials
                {
                    SourceName = "MBO.Russel.Fritch",
                    Password   = "******",
                    SiteIDs    = new ArrayOfInt {
                        -31100
                    }
                },

                StaffCredentials = new StaffCredentials
                {
                    Username = string.Format("{0}.{1}", staff.FirstName, staff.LastName),
                    Password = string.Format("{0}{1}{2}", staff.FirstName.ToLower()[0], staff.LastName.ToLower()[0], staff.ID),
                    SiteIDs  = new ArrayOfInt {
                        -31100
                    }
                },
                StartDate = appointmentDate,
                EndDate   = endDate,
            };
            var proxy = new AppointmentServiceSoapClient();
            GetStaffAppointmentsResult response = proxy.GetStaffAppointments(request);

            return(response.Appointments.Select(appointment => new AppointmentModel
            {
                ID = appointment.ID,
                StartDateTime = appointment.StartDateTime,
                EndDateTime = appointment.EndDateTime,
                ClientName = string.Format("{0} {1}", appointment.Client.FirstName, appointment.Client.LastName),
                SessionType = appointment.SessionType.Name
            }).Cast <IAppointment>().ToList());
        }