/// <summary> /// Gets the data from the web service and populates the controls. /// </summary> /// <param name="courseIds">The id's of the courses to display.</param> /// <param name="APIKey"></param> private void PopulateData(string[] courseIds, String APIKey) { ServiceInterface client = new ServiceInterfaceClient("CourseSearchService"); CourseDetailInput courseListInput = new CourseDetailInput(courseIds, APIKey); try { CourseDetailOutput courseDetailOutput = client.CourseDetail(courseListInput); List <CourseInformation> courseDetails = CreateCourseDetails(courseDetailOutput); if (courseDetails.Count() > 0) { NumberOfCourses.Text = string.Format(Constants.StringFormats.CourseDetailNoOfCourses, courseDetails.Count()); divResults.Visible = true; CourseRepeater.DataSource = courseDetails; CourseRepeater.DataBind(); } else { divResults.Visible = false; ResultsOverviewLabel.Text = "There are no results to display."; } } catch (Exception ex) { ResultsOverviewLabel.Text = ex.Message + "\n" + ex.StackTrace; } }
/// <summary> /// On clicking CourseDetail button, calls CourseSearchService ClientDetail() method with test data. /// </summary> private void btnCourseDetail_Click(object sender, EventArgs e) { txtResult.Text = "Processing ..."; ServiceInterface client = new ServiceInterfaceClient("CourseSearch"); string[] courseIds = { "53527655" }; CourseDetailInput request = new CourseDetailInput(courseIds, ""); try { CourseDetailOutput response = client.CourseDetail(request); StringBuilder sb = new StringBuilder(); sb.Append("Request details:"); foreach (string s in response.RequestDetails.CourseID) { sb.Append("\n" + s); } sb.Append("\n\n"); sb.Append("Course details:"); foreach (CourseDetailStructure courseDetail in response.CourseDetails) { sb.Append("\n" + courseDetail.Course.CourseID); sb.Append("\n" + courseDetail.Course.CourseTitle); sb.Append("\n" + courseDetail.Course.CourseSummary); sb.Append("\n" + courseDetail.Provider.ProviderID); sb.Append("\n" + courseDetail.Provider.ProviderName); sb.Append("\n" + courseDetail.Provider.UPIN); sb.Append("\n" + courseDetail.Provider.Email); sb.Append("\n" + courseDetail.Provider.Website); sb.Append("\n"); sb.Append("Opportunity details:"); foreach (OpportunityDetail opportunityDetail in courseDetail.Opportunity) { sb.Append("\n" + opportunityDetail.ProviderOpportunityId); sb.Append("\n" + opportunityDetail.URL); sb.Append("\n" + opportunityDetail.A10); sb.Append("\n" + opportunityDetail.ApplyFromDate); sb.Append("\n" + opportunityDetail.ApplyUntilDate); sb.Append("\n" + opportunityDetail.ApplyTo); sb.Append("\n" + opportunityDetail.AttendanceMode); sb.Append("\n" + opportunityDetail.AttendancePattern); sb.Append("\n" + opportunityDetail.EnquireTo); sb.Append("\n" + opportunityDetail.PlacesAvailable); sb.Append("\n" + opportunityDetail.StudyMode); sb.Append("\n" + opportunityDetail.Price); sb.Append("\n"); } sb.Append("Venue details:"); foreach (VenueDetail venueDetail in courseDetail.Venue) { sb.Append("\n" + venueDetail.VenueID); sb.Append("\n" + venueDetail.VenueName); sb.Append("\n" + venueDetail.Email); sb.Append("\n" + venueDetail.Facilities); sb.Append("\n" + venueDetail.Website); sb.Append("\n"); } sb.Append("\n"); } txtResult.Text = sb.ToString(); } catch (Exception ex) { txtResult.Text = ex.Message; } }