diff --git a/VirtoCommerce.Storefront/AutoRestClients/OrdersModuleApi.cs b/VirtoCommerce.Storefront/AutoRestClients/OrdersModuleApi.cs
index d779ffaf..512f6ceb 100644
--- a/VirtoCommerce.Storefront/AutoRestClients/OrdersModuleApi.cs
+++ b/VirtoCommerce.Storefront/AutoRestClients/OrdersModuleApi.cs
@@ -2277,7 +2277,7 @@ public OrderModule(OrdersModuleClient client)
///
/// A response object containing the response body and response headers.
///
- public async Task> GetInvoicePdfWithHttpMessagesAsync(string orderNumber, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task> GetInvoicePdfWithHttpMessagesAsync(string orderNumber, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (orderNumber == null)
{
@@ -2332,7 +2332,7 @@ public OrderModule(OrdersModuleClient client)
ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
}
cancellationToken.ThrowIfCancellationRequested();
- _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
if (_shouldTrace)
{
ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
@@ -2363,26 +2363,13 @@ public OrderModule(OrdersModuleClient client)
throw ex;
}
// Create Result
- var _result = new HttpOperationResponse();
+ var _result = new HttpOperationResponse();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
// Deserialize Response
if ((int)_statusCode == 200)
{
- _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
- try
- {
- _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
- }
- catch (JsonException ex)
- {
- _httpRequest.Dispose();
- if (_httpResponse != null)
- {
- _httpResponse.Dispose();
- }
- throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
- }
+ _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
}
if (_shouldTrace)
{
@@ -2676,6 +2663,7 @@ namespace VirtoCommerce.Storefront.AutoRestClients.OrdersModuleApi
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
+ using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
@@ -2999,7 +2987,7 @@ public partial interface IOrderModule
///
/// Thrown when a required parameter is null
///
- Task> GetInvoicePdfWithHttpMessagesAsync(string orderNumber, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ Task> GetInvoicePdfWithHttpMessagesAsync(string orderNumber, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
///
///
///
@@ -3049,6 +3037,7 @@ namespace VirtoCommerce.Storefront.AutoRestClients.OrdersModuleApi
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
+ using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
@@ -3568,7 +3557,7 @@ public static PaymentIn GetNewPayment(this IOrderModule operations, string id)
///
///
///
- public static string GetInvoicePdf(this IOrderModule operations, string orderNumber)
+ public static Stream GetInvoicePdf(this IOrderModule operations, string orderNumber)
{
return operations.GetInvoicePdfAsync(orderNumber).GetAwaiter().GetResult();
}
@@ -3581,12 +3570,11 @@ public static string GetInvoicePdf(this IOrderModule operations, string orderNum
///
/// The cancellation token.
///
- public static async Task GetInvoicePdfAsync(this IOrderModule operations, string orderNumber, CancellationToken cancellationToken = default(CancellationToken))
+ public static async Task GetInvoicePdfAsync(this IOrderModule operations, string orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
- using (var _result = await operations.GetInvoicePdfWithHttpMessagesAsync(orderNumber, null, cancellationToken).ConfigureAwait(false))
- {
- return _result.Body;
- }
+ var _result = await operations.GetInvoicePdfWithHttpMessagesAsync(orderNumber, null, cancellationToken).ConfigureAwait(false);
+ _result.Request.Dispose();
+ return _result.Body;
}
///
@@ -3657,7 +3645,6 @@ namespace VirtoCommerce.Storefront.AutoRestClients.OrdersModuleApi
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
- using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
diff --git a/VirtoCommerce.Storefront/Controllers/Api/ApiOrderController.cs b/VirtoCommerce.Storefront/Controllers/Api/ApiOrderController.cs
index 592fac4b..62947287 100644
--- a/VirtoCommerce.Storefront/Controllers/Api/ApiOrderController.cs
+++ b/VirtoCommerce.Storefront/Controllers/Api/ApiOrderController.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
@@ -262,7 +263,7 @@ public async Task GetInvoicePdf(string orderNumber)
return Unauthorized();
}
- var stream = await _orderApi.GetInvoicePdfAsync(order.Number);
+ Stream stream = await _orderApi.GetInvoicePdfAsync(order.Number);
return File(stream, "application/pdf");
}