This commit is contained in:
sysadmin
2025-08-27 22:19:39 +01:00
parent 5c6abe5686
commit bbf5acbb6b
22 changed files with 15571 additions and 6 deletions

View File

@@ -64,6 +64,30 @@ public class OrderService : IOrderService
System.Net.HttpStatusCode.InternalServerError);
}
}
public async Task<ApiResponse<List<Order>>> GetOrdersByCustomerIdAsync(Guid customerId)
{
try
{
var response = await _httpClient.GetAsync($"api/orders/by-customer/{customerId}");
if (response.IsSuccessStatusCode)
{
var orders = await response.Content.ReadFromJsonAsync<List<Order>>();
return ApiResponse<List<Order>>.Success(orders ?? new List<Order>());
}
var error = await response.Content.ReadAsStringAsync();
return ApiResponse<List<Order>>.Failure(error, response.StatusCode);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to get orders for customer {CustomerId}", customerId);
return ApiResponse<List<Order>>.Failure(
ex.Message,
System.Net.HttpStatusCode.InternalServerError);
}
}
public async Task<ApiResponse<Order>> GetOrderByIdAsync(Guid id)
{