26 lines
773 B
C#
26 lines
773 B
C#
using ApiRestaurant.Models;
|
|
|
|
namespace ApiRestaurant;
|
|
|
|
public static class WaiterApiClient
|
|
{
|
|
public static string WaiterApiAddress { get; private set; } = string.Empty;
|
|
private static readonly HttpClient client = new();
|
|
|
|
public static void Setup(string waiterApiAddress)
|
|
{
|
|
WaiterApiAddress = waiterApiAddress;
|
|
}
|
|
public static async Task<List<Waiter>> GetAllForRestaurant(Guid restaurantId) {
|
|
try
|
|
{
|
|
var waiters = await client.GetFromJsonAsync<List<Waiter>>(WaiterApiAddress + $"from-restaurant/{restaurantId}");
|
|
return waiters ?? [];
|
|
}
|
|
catch (HttpRequestException ex)
|
|
{
|
|
Console.WriteLine($"Error fetching waiters: {ex.Message}");
|
|
throw;
|
|
}
|
|
}
|
|
} |