Exemplo n.º 1
0
        /// <summary>
        /// Action used to update the votes of the current error
        /// </summary>
        /// <param name="id">id of the error</param>
        /// <param name="error">error object that has the current votes</param>
        /// <returns>A status code based on the result</returns>
        public static async Task <HttpStatusCode> APICallUpVoteError(int id, Error error)
        {
            APICallModel apm = new APICallModel();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(apm.URL);
                var response = await client.PutAsJsonAsync($"/api/error/{id}", error.Votes);

                return(response.StatusCode);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Action used to make a request to the Broken API to find Errors
        /// based off of the search word
        /// </summary>
        /// <param name="search">Search word</param>
        /// <returns>Error Results</returns>
        public static async Task <string> APICallErrorResults(string error)
        {
            APICallModel apm = new APICallModel();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(apm.URL);
                var response = client.GetAsync($"api/error/search/{error}").Result;

                if (response.EnsureSuccessStatusCode().IsSuccessStatusCode)
                {
                    string ErrorResults = await response.Content.ReadAsStringAsync();

                    return(ErrorResults);
                }
                return("");
            }
        }