public ActionResult AddOrUpdateAppointmentsRequest(AddOrUpdateAppointmentsModel model)
        {
            var request = addOrUpdateAppointments(model);
            var response = appointmentService.AddOrUpdateAppointments(request);

            @ViewBag.Request_JSON = JsonConvert.SerializeObject(request, Formatting.Indented, new JsonConverter[] { new StringEnumConverter() });
            @ViewBag.Response_JSON = JsonConvert.SerializeObject(response, Formatting.Indented, new JsonConverter[] { new StringEnumConverter() });

            @ViewBag.Request_SOAP = SoapSerializer.SerializeToSoap<AddOrUpdateAppointmentsRequest>(request);
            @ViewBag.Response_SOAP = SoapSerializer.SerializeToSoap<AddOrUpdateAppointmentsResult>(response);

            return View();
        }
        private AppointmentService.SessionType getSessionType(AddOrUpdateAppointmentsModel model, int index)
        {
            return new AppointmentService.SessionType
                       {
                           ID = model.Appointments[index].appt_SessionType.sestp_ID,
                           Name = model.Appointments[index].appt_SessionType.sestp_Name,

                           IDSpecified = model.Appointments[index].appt_SessionType.sestp_ID >= 0
                       };
        }
 private AppointmentService.Staff getStaff(AddOrUpdateAppointmentsModel model, int index)
 {
     return new AppointmentService.Staff
                {
                    Email = model.Appointments[index].appt_Staff.staff_Email,
                    MobilePhone = model.Appointments[index].appt_Staff.staff_MobilePhone,
                    HomePhone = model.Appointments[index].appt_Staff.staff_HomePhone,
                    WorkPhone = model.Appointments[index].appt_Staff.staff_WorkPhone,
                    Address = model.Appointments[index].appt_Staff.staff_Address,
                    Address2 = model.Appointments[index].appt_Staff.staff_Address2,
                    City = model.Appointments[index].appt_Staff.staff_City,
                    State = model.Appointments[index].appt_Staff.staff_State,
                    Country = model.Appointments[index].appt_Staff.staff_Country,
                    PostalCode = model.Appointments[index].appt_Staff.staff_PostalCode,
                    ForeignZip = model.Appointments[index].appt_Staff.staff_ForeignZip,
                    ID = model.Appointments[index].appt_Staff.staff_ID,
                    Name = model.Appointments[index].appt_Staff.staff_Name,
                    FirstName = model.Appointments[index].appt_Staff.staff_FirstName,
                    LastName = model.Appointments[index].appt_Staff.staff_LastName
                };
 }
 /**********************************************AddOrUpdateAppointments******************************************************/
 //This is a hefty-ass one
 private AppointmentService.Program getProgram(AddOrUpdateAppointmentsModel model, int index)
 {
     return new AppointmentService.Program
                {
                    ID = model.Appointments[index].appt_Program.prgm_ID,
                    Name = model.Appointments[index].appt_Program.prgm_Name
                };
 }
 //TODO Support multiple resources
 private AppointmentService.Resource[] getResources(AddOrUpdateAppointmentsModel model, int index)
 {
     return new []
                {
                    new Resource
                        {
                            ID = model.Appointments[index].appt_Resources[0].res_ID,
                            Name = model.Appointments[index].appt_Resources[0].res_Name
                        }
                };
 }
 private AppointmentService.Location getLocation(AddOrUpdateAppointmentsModel model, int index)
 {
     return new AppointmentService.Location
                {
                    BusinessID = model.Appointments[index].appt_Location.loc_BusinessID,
                    SiteID = model.Appointments[index].appt_Location.loc_SiteID,
                    BusinessDescription = model.Appointments[index].appt_Location.loc_BusinessDescription,
                    AdditionalImageURLs = ("," + model.Appointments[index].appt_Location.loc_AddImageUrls).Split(','),
                    FacilitySquareFeet = model.Appointments[index].appt_Location.loc_FacilitySqFt,
                    TreatmentRooms = model.Appointments[index].appt_Location.loc_TreamentRooms,
                    ProSpaFinderSite = model.Appointments[index].appt_Location.loc_SpaFinderSite,
                    HasClasses = model.Appointments[index].appt_Location.loc_HasClasses,
                    PhoneExtension = model.Appointments[index].appt_Location.loc_PhoneExt,
                    ID = model.Appointments[index].appt_Location.loc_ID,
                    Name = model.Appointments[index].appt_Location.loc_Name,
                    Latitude = model.Appointments[index].appt_Location.loc_Latitude,
                    Longitude = model.Appointments[index].appt_Location.loc_Longitude,
                    DistanceInMiles = model.Appointments[index].appt_Location.loc_DistanceInMiles,
                    ImageURL = model.Appointments[index].appt_Location.loc_ImageURL,
                    Description = model.Appointments[index].appt_Location.loc_Description,
                    HasSite = model.Appointments[index].appt_Location.loc_HasSite,
                    CanBook = model.Appointments[index].appt_Location.loc_CanBook
                };
 }
 private AppointmentService.ClientService getClientService(AddOrUpdateAppointmentsModel model, int index)
 {
     return new AppointmentService.ClientService
                {
                    ID = model.Appointments[index].appt_ClientService.cltsv_ID,
                    Name = model.Appointments[index].appt_ClientService.cltsv_Name
                };
 }
 private AppointmentService.Client getClient(AddOrUpdateAppointmentsModel model, int index)
 {
     return new AppointmentService.Client
                {
                    ID = model.Appointments[index].appt_Client.clt_ID,
                    FirstName = model.Appointments[index].appt_Client.clt_FirstName,
                    LastName = model.Appointments[index].appt_Client.clt_LastName,
                    Email = model.Appointments[index].appt_Client.clt_Email,
                    MobilePhone = model.Appointments[index].appt_Client.clt_MobilePhone,
                    HomePhone = model.Appointments[index].appt_Client.clt_HomePhone
                };
 }
        private AppointmentService.Appointment[] getAppointments(AddOrUpdateAppointmentsModel model)
        {
            var appointments = new List<AppointmentService.Appointment>();
            System.Diagnostics.Debug.WriteLine("appointmentsCount is " + model.appointmentsCount);
            for (int i = 0; i < model.appointmentsCount; i++)
            {
                var appointment = new Appointment
                                      {
                                          ID = model.Appointments[i].appt_ID,
                                          Status = model.Appointments[i].appt_Status,

                                          StartDateTime = model.Appointments[i].appt_StartDateTime,
                                          StartDateTimeSpecified = model.Appointments[i].appt_StartDateTime != null,

                                          Notes = model.Appointments[i].appt_Notes,
                                          Program = getProgram(model, i),
                                          SessionType = getSessionType(model, i),
                                          Location = getLocation(model, i),
                                          Staff = getStaff(model, i),
                                          Client = getClient(model, i),
                                          FirstAppointment = model.Appointments[i].appt_FirstAppointment,
                                          ClientService = getClientService(model, i),
                                          Resources = getResources(model, i)
                                      };
                appointments.Add(appointment);
            }
            return appointments.ToArray();
        }
        private AddOrUpdateAppointmentsRequest addOrUpdateAppointments(AddOrUpdateAppointmentsModel model)
        {
            System.Diagnostics.Debug.WriteLine("User Credentials: " + getUserCredentials(model));

            var request = APISettings.getBaseAppointmentRequest<AddOrUpdateAppointmentsRequest>(model);

            request.UpdateAction = model.UpdateAction;
            request.Test = model.Test;
            request.SendEmail = model.SendEmail;
            request.ApplyPayment = model.ApplyPayment;
            request.Appointments = getAppointments(model);

            return request;
        }