final
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user