Exemplo n.º 1
0
        public static ByteArrayContent MakeJsonObject(BoonLeague boon)
        {
            var json        = JsonConvert.SerializeObject(boon);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(json);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            return(byteContent);
        }
Exemplo n.º 2
0
        public static async Task <BoonLeague> GetData(HttpClient client)
        {
            using (HttpResponseMessage response = await client.GetAsync("api/BoonLeague"))
            {
                if (response.IsSuccessStatusCode)
                {
                    BoonLeague boon = await response.Content.ReadAsAsync <BoonLeague>();

                    return(boon);
                }
                else
                {
                    return(null);
                }
            }
        }