Esempio n. 1
0
        public async Task <IHttpActionResult> Retrieve(string id)
        {
            var uri            = $"{LegacyServiceUrlFactory.Create(LegacyServiceEndpoint.Retrieve)}/{id}";
            var client         = new HttpClient();
            var legacyResponse = await client.GetAsync(uri);

            Func <string, string> okFuncContent = content => content;

            return(await HandleLegacyResponse(legacyResponse, okFuncContent));
        }
Esempio n. 2
0
        /// <summary>
        /// Helper method used from the Upload Endpoint in order to communicate with the corresponding Endpoint of the Legacy API.
        /// </summary>
        /// <param name="documentPayload">The document that should be uploaded.</param>
        /// <returns></returns>
        private async Task <ResponseMessageResult> InternalUpload(DocumentPayload documentPayload)
        {
            var          client  = new HttpClient();
            const string appJson = "application/json";

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(appJson));
            var strContent     = new StringContent(JsonConvert.SerializeObject(documentPayload), Encoding.UTF8, appJson);
            var uri            = LegacyServiceUrlFactory.Create(LegacyServiceEndpoint.Upload);
            var legacyResponse = await client.PostAsync(uri, strContent);

            Func <string, UploadFileResponse> okFuncContent = JsonConvert.DeserializeObject <UploadFileResponse>;

            return(await HandleLegacyResponse(legacyResponse, okFuncContent));
        }