38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Net.Http.Headers;
|
|
using Blazored.LocalStorage;
|
|
using FaKrosnoEfDataModel.Dtos;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
|
|
namespace OrdersManagement.Services;
|
|
|
|
public class ScheduleOrderService(
|
|
IHttpClientFactory httpClientFactory,
|
|
AuthenticationStateProvider authenticationStateProvider)
|
|
: ServiceBase<ScheduleOrderDto>(httpClientFactory, authenticationStateProvider)
|
|
{
|
|
public async Task<IEnumerable<ScheduleOrderDto>?> GetScheduleOrdersAsync()
|
|
{
|
|
try
|
|
{
|
|
return await GetListAsync("api/ScheduleOrders");
|
|
}
|
|
catch (HttpRequestException ex)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
} |