Esempio n. 1
0
 public async Task <ResponseModel <TResponse> > PostAsync <TResponse, TRequest>(string requestUri, TRequest request, bool runAsync = true)
 {
     using (var client = new CoreHttpClient(baseUri))
     {
         //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", D2I_CommonTypes.D2I_Sessions.Token);
         var response = await client.PostAsJsonAsync(requestUri, request)
                        .ContinueWith(r => ReadAsync <TResponse>(r.Result)).ConfigureAwait(runAsync);;
         return(await response);
     }
 }
Esempio n. 2
0
 public ResponseModel <TResponse> Post <TResponse, TRequest>(string requestUri, HttpContent request, bool runAsync = false)
 {
     using (var client = new CoreHttpClient(baseUri))
     {
         //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", D2I_CommonTypes.D2I_Sessions.Token);
         var response = client.PostAsync(requestUri, request).Result;
         var result   = ReadAsync <TResponse>(response).Result;
         return(result);
     }
 }
Esempio n. 3
0
 public ResponseModel <TResponse> Get <TResponse>(string requestUri)
 {
     using (var client = new CoreHttpClient(baseUri))
     {
         //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", D2I_CommonTypes.D2I_Sessions.Token);
         var response = client.GetAsync(requestUri, HttpCompletionOption.ResponseContentRead).Result;
         var result   = ReadAsync <TResponse>(response).Result;
         return(result);
     }
 }