using OI.Metrology.Shared.Models.Stateless; using Microsoft.AspNetCore.Components; using System.Net.Http.Json; namespace OI.Metrology.Client.Pages; public partial class AwaitingDisposition { [Inject] protected HttpClient? HttpClient { get; set; } [Inject] protected ILogger? Logger { get; set; } private Metrology.Shared.DataModels.AwaitingDisposition[]? _Records; protected override async Task OnInitializedAsync() { if (Logger is null) throw new NullReferenceException(nameof(Logger)); if (HttpClient is null) throw new NullReferenceException(nameof(HttpClient)); string controllerName = IAwaitingDispoController.GetRouteName(); try { _Records = await HttpClient.GetFromJsonAsync($"api/{controllerName}"); } catch (Exception) { string json = await HttpClient.GetStringAsync($"api/{controllerName}"); Logger.LogInformation(message: json); } } }