"Fix-order-details-for-customers"

This commit is contained in:
sysadmin
2025-08-27 23:35:30 +01:00
parent 1829e5c940
commit 5748ed4a09
8 changed files with 103 additions and 18 deletions

View File

@@ -113,6 +113,31 @@ public class OrderService : IOrderService
System.Net.HttpStatusCode.InternalServerError);
}
}
public async Task<ApiResponse<Order>> GetOrderByCustomerIdAsync(Guid customerId, Guid orderId)
{
try
{
var response = await _httpClient.GetAsync($"api/orders/by-customer/{customerId}/{orderId}");
if (response.IsSuccessStatusCode)
{
var order = await response.Content.ReadFromJsonAsync<Order>();
if (order != null)
return ApiResponse<Order>.Success(order);
}
var error = await response.Content.ReadAsStringAsync();
return ApiResponse<Order>.Failure(error, response.StatusCode);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to get order {OrderId} for customer {CustomerId}", orderId, customerId);
return ApiResponse<Order>.Failure(
ex.Message,
System.Net.HttpStatusCode.InternalServerError);
}
}
public async Task<ApiResponse<CryptoPayment>> CreatePaymentAsync(Guid orderId, int currency)
{