* Added Authorization which is not working
This commit is contained in:
@@ -1,17 +1,36 @@
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
|
||||
namespace OrdersManagement.Services;
|
||||
|
||||
public class CustomerOrderService(HttpClient httpClient)
|
||||
public class CustomerOrderService(
|
||||
IHttpClientFactory httpClientFactory,
|
||||
AuthenticationStateProvider authenticationStateProvider)
|
||||
: ServiceBase<CustomerOrderDto>(httpClientFactory, authenticationStateProvider)
|
||||
{
|
||||
public async Task<IEnumerable<CustomerOrderDto>?> GetCustomerOrdersAsync()
|
||||
{
|
||||
return await httpClient.GetFromJsonAsync<IEnumerable<CustomerOrderDto>>("api/CustomerOrders");
|
||||
try
|
||||
{
|
||||
return await GetListAsync("api/CustomerOrders");
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Console.WriteLine($"Błąd HTTP w GetCustomerOrdersAsync: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<CustomerOrderDto?> GetCustomerOrderAsync(Guid customerOrderNumber)
|
||||
{
|
||||
return await httpClient.GetFromJsonAsync<CustomerOrderDto>(
|
||||
$"api/CustomerOrders/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
||||
try
|
||||
{
|
||||
return await GetByIdAsync($"api/CustomerOrders/by-order-number/?customerOrderNumber={customerOrderNumber}");
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Console.WriteLine($"Błąd HTTP w GetScheduleOrderAsync: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user