fetchServiceShoporders works

This commit is contained in:
2023-01-06 21:54:20 -07:00
parent f0c2140f93
commit b6868e2608
41 changed files with 1384 additions and 0 deletions

View File

@ -0,0 +1,43 @@
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.ViewModels;
using Microsoft.AspNetCore.Components;
using System.Net.Http.Json;
namespace OI.Metrology.Client.Pages;
public partial class FetchServiceShopOrders
{
[Inject] protected HttpClient? HttpClient { get; set; }
[Inject] protected ILogger<FetchServiceShopOrders>? 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<object>.Action.All);
string controllerName = IServiceShopOrderController<object>.GetRouteName();
try
{ _ServiceShopOrders = await HttpClient.GetFromJsonAsync<ServiceShopOrder[]>($"api/{controllerName}/{actionName}"); }
catch (Exception)
{
string json = await HttpClient.GetStringAsync($"api/{controllerName}/{actionName}");
Logger.LogInformation(message: json);
}
}
}