CORS, Theme, Better flow and dotnet tools - II
This commit is contained in:
@ -7,16 +7,24 @@ namespace Expose.MyIT.Client.Pages;
|
||||
public partial class FetchData
|
||||
{
|
||||
|
||||
[Inject] protected HttpClient? Http { get; set; }
|
||||
[Inject] protected HttpClient? HttpClient { get; set; }
|
||||
[Inject] protected ILogger<FetchData>? Logger { get; set; }
|
||||
|
||||
private WeatherForecast[]? _Forecasts;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (Http is null)
|
||||
throw new NullReferenceException(nameof(Http));
|
||||
string controllerName = MyIT.Shared.Models.Stateless.Methods.IWeatherForecastController.GetRouteName();
|
||||
// _SsaOrders = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
|
||||
_Forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>($"api/{controllerName}");
|
||||
if (Logger is null)
|
||||
throw new NullReferenceException(nameof(Logger));
|
||||
if (HttpClient is null)
|
||||
throw new NullReferenceException(nameof(HttpClient));
|
||||
string controllerName = MyIT.Shared.Models.Stateless.IWeatherForecastController<object>.GetRouteName();
|
||||
try
|
||||
{ _Forecasts = await HttpClient.GetFromJsonAsync<WeatherForecast[]>($"api/{controllerName}"); }
|
||||
catch (Exception)
|
||||
{
|
||||
string json = await HttpClient.GetStringAsync($"api/{controllerName}");
|
||||
Logger.LogInformation(message: json);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Expose.MyIT.Shared.Models.Stateless;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
@ -7,7 +8,8 @@ namespace Expose.MyIT.Client.Pages;
|
||||
public partial class FetchServiceShopOrders
|
||||
{
|
||||
|
||||
[Inject] protected HttpClient? Http { get; set; }
|
||||
[Inject] protected HttpClient? HttpClient { get; set; }
|
||||
[Inject] protected ILogger<FetchServiceShopOrders>? Logger { get; set; }
|
||||
|
||||
private ServiceShopOrder[]? _ServiceShopOrders;
|
||||
|
||||
@ -24,10 +26,18 @@ public partial class FetchServiceShopOrders
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (Http is null)
|
||||
throw new NullReferenceException(nameof(Http));
|
||||
string controllerName = MyIT.Shared.Models.Stateless.Methods.IServiceShopOrderController.GetRouteName();
|
||||
string actionName = nameof(MyIT.Shared.Models.Stateless.Methods.ISsaOrderController.GetAllSsaOrders).Substring(3, 3);
|
||||
_ServiceShopOrders = await Http.GetFromJsonAsync<ServiceShopOrder[]>($"api/{controllerName}/{actionName}");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
42
Client/Pages/FetchSsaOrders.razor
Normal file
42
Client/Pages/FetchSsaOrders.razor
Normal file
@ -0,0 +1,42 @@
|
||||
@page "/fetchssaorders"
|
||||
@using Expose.MyIT.Shared.ViewModels
|
||||
|
||||
<PageTitle>SSA Orders</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h3" GutterBottom="true">SSA Orders</MudText>
|
||||
@if (_SsaOrders == null)
|
||||
{
|
||||
<MudProgressCircular Color="Color.Default" Indeterminate="true" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTable Items="_SsaOrders" Hover="true" SortLabel="Sort By" Elevation="0">
|
||||
<HeaderContent>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Id)">Id</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Name)">Name</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.BookingNames)">Booking Names</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Type)">Type</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.State)">State</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.ItemNumber)">Item Number</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel InitialDirection="SortDirection.Descending" SortBy="new Func<SsaOrder, object>(x=>x.CreatedDate)">Created Date</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.DecidedDate)">Decided Date</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Recipient)">Recipient</MudTableSortLabel></MudTh>
|
||||
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Requestor)">Requestor</MudTableSortLabel></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Id">@context.Id</MudTd>
|
||||
<MudTd DataLabel="Name">@context.Name</MudTd>
|
||||
<MudTd DataLabel="BookingNames">@string.Join(' ', context.BookingNames)</MudTd>
|
||||
<MudTd DataLabel="Type">@context.Type</MudTd>
|
||||
<MudTd DataLabel="State">@context.State</MudTd>
|
||||
<MudTd DataLabel="ItemNumber">@context.ItemNumber</MudTd>
|
||||
<MudTd DataLabel="CreatedDate">@context.CreatedDate</MudTd>
|
||||
<MudTd DataLabel="DecidedDate">@context.DecidedDate</MudTd>
|
||||
<MudTd DataLabel="Recipient">@context.Recipient</MudTd>
|
||||
<MudTd DataLabel="Requestor">@context.Requestor</MudTd>
|
||||
</RowTemplate>
|
||||
<PagerContent>
|
||||
<MudTablePager PageSizeOptions="new int[]{50, 100}" />
|
||||
</PagerContent>
|
||||
</MudTable>
|
||||
}
|
43
Client/Pages/FetchSsaOrders.razor.cs
Normal file
43
Client/Pages/FetchSsaOrders.razor.cs
Normal file
@ -0,0 +1,43 @@
|
||||
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 FetchSsaOrders
|
||||
{
|
||||
|
||||
[Inject] protected HttpClient? HttpClient { get; set; }
|
||||
[Inject] protected ILogger<Counter>? Logger { get; set; }
|
||||
|
||||
private SsaOrder[]? _SsaOrders;
|
||||
|
||||
//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(ISsaOrderController<object>.Action.All);
|
||||
string controllerName = ISsaOrderController<object>.GetRouteName();
|
||||
try
|
||||
{ _SsaOrders = await HttpClient.GetFromJsonAsync<SsaOrder[]>($"api/{controllerName}/{actionName}"); }
|
||||
catch (Exception)
|
||||
{
|
||||
string json = await HttpClient.GetStringAsync($"api/{controllerName}/{actionName}");
|
||||
Logger.LogInformation(message: json);
|
||||
}
|
||||
}
|
||||
}
|
4
Client/Pages/Index.razor.cs
Normal file
4
Client/Pages/Index.razor.cs
Normal file
@ -0,0 +1,4 @@
|
||||
namespace Expose.MyIT.Client.Pages;
|
||||
|
||||
public partial class Index
|
||||
{ }
|
Reference in New Issue
Block a user