//GetJokeCount public int GetJokeCount(Enums.JokeFilter filter) { string responseText = "0"; var client = new RestClient(baseUrl); RestRequest request = null; switch (filter) { case Enums.JokeFilter.MostRecent: request = new RestRequest(String.Format(getJokeCountUrl, "1")); break; case Enums.JokeFilter.MostPopular: request = new RestRequest(String.Format(getJokeCountUrl, "2")); break; case Enums.JokeFilter.MostRecentNoExplicit: request = new RestRequest(String.Format(getJokeCountUrl, "3")); break; case Enums.JokeFilter.MostPopularNoExplicit: request = new RestRequest(String.Format(getJokeCountUrl, "4")); break; default: request = new RestRequest(String.Format(getJokeCountUrl, "3")); break; } try { IRestResponse response = client.Execute(request); responseText = response.Content; } catch (WebException exc) { } finally { client = null; request = null; } return(int.Parse(responseText)); }
//GetJokes public List <Joke> GetJokes(Enums.JokeFilter filter, int page) { var client = new RestClient(baseUrl); RestRequest request = null; switch (filter) { case Enums.JokeFilter.MostRecent: request = new RestRequest(String.Format(getJokesUrl, "1", page)); break; case Enums.JokeFilter.MostPopular: request = new RestRequest(String.Format(getJokesUrl, "2", page)); break; case Enums.JokeFilter.MostRecentNoExplicit: request = new RestRequest(String.Format(getJokesUrl, "3", page)); break; case Enums.JokeFilter.MostPopularNoExplicit: request = new RestRequest(String.Format(getJokesUrl, "4", page)); break; default: request = new RestRequest(String.Format(getJokesUrl, "3", page)); break; } try { IRestResponse <List <Joke> > response = client.Execute <List <Joke> >(request); jokeList = response.Data; } catch (WebException exc) { } finally { client = null; request = null; } return(jokeList); }
public JokesViewController(Enums.JokeFilter filter) : base("JokesViewController", null) { this.filter = filter; }