using Expose.MyIT.Shared.Models.Stateless; using Expose.MyIT.Shared.ViewModels; using Microsoft.AspNetCore.Components; using System.Net.Http.Json; namespace Expose.MyIT.Client.Pages; public partial class FetchServiceShopOrders { [Inject] protected HttpClient? HttpClient { get; set; } [Inject] protected ILogger? Logger { get; set; } private ServiceShopOrder[]? _ServiceShopOrders; //Id //Name //BookingNames //Type //State //ItemNumber //CreatedDate //DecidedDate //Recipient //Requestor protected override async Task OnInitializedAsync() { if (Logger is null) throw new NullReferenceException(nameof(Logger)); if (HttpClient is null) throw new NullReferenceException(nameof(HttpClient)); string actionName = nameof(IServiceShopOrderController.Action.All); string controllerName = IServiceShopOrderController.GetRouteName(); try { _ServiceShopOrders = await HttpClient.GetFromJsonAsync($"api/{controllerName}/{actionName}"); } catch (Exception) { string json = await HttpClient.GetStringAsync($"api/{controllerName}/{actionName}"); Logger.LogInformation(message: json); } } }