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); }
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); } } }
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); } } }