Example #1
0
        public async Task <TResultQuery> GetAsync <TResultQuery>(Uri uri)
            where TResultQuery : class
        {
            TResultQuery resultQuery;

            using (var httpClient = new HttpClient())
            {
                httpClient.AddCredentials();
                var responce = await httpClient.GetAsync(uri);

                resultQuery = await GetContentResponce <TResultQuery>(responce);
            }

            return(resultQuery);
        }
Example #2
0
        public async Task <bool> PostAsync(Uri uri)
        {
            using (var httpClient = new HttpClient())
            {
                httpClient.AddCredentials();
                var content  = new StringContent("");
                var responce = await httpClient.PostAsync(uri, content);

                if (responce.StatusCode == HttpStatusCode.OK)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #3
0
        public async Task <bool> PostAsync <TBodyQuery>(Uri uri, TBodyQuery bodyQuery)
            where TBodyQuery : class
        {
            using (var httpClient = new HttpClient())
            {
                httpClient.AddCredentials();
                var content  = new StringContent(JsonConvert.SerializeObject(bodyQuery), Encoding.UTF8, "application/json");
                var responce = await httpClient.PostAsync(uri, content);

                if (responce.StatusCode == HttpStatusCode.OK)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }