fetchServiceShoporders works
This commit is contained in:
43
Client/Pages/FetchServiceShopOrders.razor.cs
Normal file
43
Client/Pages/FetchServiceShopOrders.razor.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user