private void button1_Click(object sender, EventArgs e) { maximumPage = 0; //RestClientClass rClient = new RestClientClass(); theResponse = null; rClient.title = null; rClient.type = null; rClient.year = null; if (textTitle.Text != null && textType.Text == null && textYear.Text == null) { rClient.title = "s=" + textTitle.Text; rClient.endPoint = rClient.key + rClient.title; } if (textTitle.Text != null && textType.Text != null && textYear.Text == null) { rClient.title = "s=" + textTitle.Text; rClient.type = "&type=" + textType.Text; rClient.endPoint = rClient.key + rClient.title + rClient.type; } if (textTitle.Text != null && textType.Text == null && textYear.Text != null) { rClient.title = "s=" + textTitle.Text; rClient.year = "&y=" + textYear.Text; rClient.endPoint = rClient.key + rClient.title + rClient.year; } if (textTitle.Text != null && textType.Text != null && textYear.Text != null) { rClient.title = "s=" + textTitle.Text; rClient.type = "&type=" + textType.Text; rClient.year = "&y=" + textYear.Text; rClient.endPoint = rClient.key + rClient.title + rClient.type + rClient.year; } theResponse = rClient.makeRequest(); firstCall = rClient.endPoint; PageIndicator.Clear(); listResponse.Items.Clear(); listType.Items.Clear(); listYear.Items.Clear(); int totalResults = Convert.ToInt32(theResponse.totalResults); maximumPage = (int)Math.Ceiling((double)totalResults / theResponse.Search.Length); page = 1; if (page != maximumPage) { GoRight.Enabled = true; GoToLastPage.Enabled = true; } for (int i = 0; i < theResponse.Search.Length; i++) { listResponse.Items.Add(theResponse.Search[i].Title); listType.Items.Add(theResponse.Search[i].Type); listYear.Items.Add(theResponse.Search[i].Year); } debugOutput("1"); }
private void GoToFirstPage_Click(object sender, EventArgs e) { if (page != 1) { page = 1; PageIndicator.Clear(); listResponse.Items.Clear(); listType.Items.Clear(); listYear.Items.Clear(); rClient.endPoint = firstCall + "&page=" + page; theResponse = rClient.makeRequest(); for (int i = 0; i < theResponse.Search.Length; i++) { listResponse.Items.Add(theResponse.Search[i].Title); listType.Items.Add(theResponse.Search[i].Type); listYear.Items.Add(theResponse.Search[i].Year); } debugOutput(page.ToString()); } if (page == 1) { GoLeft.Enabled = false; GoToFirstPage.Enabled = false; } else { GoLeft.Enabled = true; GoToFirstPage.Enabled = true; } if (page == maximumPage) { GoRight.Enabled = false; GoToLastPage.Enabled = false; } else { GoRight.Enabled = true; GoToLastPage.Enabled = true; } }