* Added Authorization which is not working

This commit is contained in:
2025-02-23 21:19:04 +01:00
parent 6774311433
commit 5bcf406465
29 changed files with 407 additions and 210 deletions

View File

@@ -1,18 +1,38 @@
using FaKrosnoEfDataModel.Dtos;
using System.Net.Http.Headers;
using Blazored.LocalStorage;
using FaKrosnoEfDataModel.Dtos;
using Microsoft.AspNetCore.Components.Authorization;
namespace OrdersManagement.Services
namespace OrdersManagement.Services;
public class ScheduleOrderService(
IHttpClientFactory httpClientFactory,
AuthenticationStateProvider authenticationStateProvider)
: ServiceBase<ScheduleOrderDto>(httpClientFactory, authenticationStateProvider)
{
public class ScheduleOrderService(HttpClient httpClient)
public async Task<IEnumerable<ScheduleOrderDto>?> GetScheduleOrdersAsync()
{
public async Task<IEnumerable<ScheduleOrderDto>?> GetScheduleOrdersAsync()
try
{
return await httpClient.GetFromJsonAsync<IEnumerable<ScheduleOrderDto>>("api/ScheduleOrders");
return await GetListAsync("api/ScheduleOrders");
}
public async Task<ScheduleOrderDto?> GetScheduleOrderAsync(int scheduleOrderId)
catch (HttpRequestException ex)
{
return await httpClient.GetFromJsonAsync<ScheduleOrderDto>(
$"api/ScheduleOrders/{scheduleOrderId}");
Console.WriteLine($"Błąd HTTP w GetScheduleOrdersAsync: {ex.Message}");
return null;
}
}
}
public async Task<ScheduleOrderDto?> GetScheduleOrderAsync(int scheduleOrderId)
{
try
{
return await GetByIdAsync($"api/ScheduleOrders/{scheduleOrderId}");
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Błąd HTTP w GetScheduleOrderAsync: {ex.Message}");
return null;
}
}
}