Gremlin/Gremlin_BlazorServer/Pages/LineItems.razor.cs

35 lines
1.3 KiB
C#

using System.Globalization;
using System.Security.Claims;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using NuGet.Packaging;
namespace Gremlin_BlazorServer.Pages;
public partial class LineItems {
private readonly CultureInfo cultureInfo = new("de-DE");
private readonly IList<LineItem> lineItems=new List<LineItem>();
private LineItem selectedLineItem = new();
[CascadingParameter] private Task<AuthenticationState>? AuthenticationStateTask { get; set; }
protected override async Task OnInitializedAsync() {
if (AuthenticationStateTask != null) {
ClaimsPrincipal user = (await AuthenticationStateTask).User;
if (user.Identity is{ IsAuthenticated: true }) {
await ApplicationLoadingIndicatorService.Show();
lineItems.AddRange(await GenericController.GetAllAsync<LineItem>());
selectedLineItem = lineItems.First();
await OnSelectedLineItemChanged(selectedLineItem);
await ApplicationLoadingIndicatorService.Hide();
}
}
}
private async Task OnSelectedLineItemChanged(LineItem newSelectedLineItem) {
await ApplicationLoadingIndicatorService.Show();
selectedLineItem = newSelectedLineItem;
await ApplicationLoadingIndicatorService.Hide();
}
}