using System.Globalization; using System.Security.Claims; using Gremlin_BlazorServer.Data.EntityClasses; using Gremlin_BlazorServer.Services; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; namespace Gremlin_BlazorServer.Pages.Quotes; public partial class QuoteIndex { private readonly CultureInfo cultureInfo = new("de-DE"); private IList? quotes; private Quote? selectedQuote; private string selectedTab = "details"; [CascadingParameter] private Task? AuthenticationStateTask { get; set; } protected override async Task OnInitializedAsync() { if (AuthenticationStateTask != null) { ClaimsPrincipal user = (await AuthenticationStateTask).User; if (user.Identity is { IsAuthenticated: true }) quotes = await GenericController.GetAllAsync(); } await base.OnInitializedAsync(); } private async Task OnSelectedQuoteChanged(Quote selectedQuote) { this.selectedQuote = selectedQuote; this.selectedQuote.Recipient = GenericController.Get(c => c.ContactId.Equals(this.selectedQuote.RecipientId)); if (this.selectedQuote.Recipient != null && this.selectedQuote != null) { this.selectedQuote = await GenericController.Get(c => c.QuoteId.Equals(selectedQuote.QuoteId), "Recipient", "LineItems"); this.selectedQuote.Recipient.Account = GenericController.Get(a => a.AccountId.Equals(this.selectedQuote.Recipient.AccountId)); } //selectedQuote.LineItems = await genericController.GetAllAsync(lI => lI.Quote.Equals(selectedQuote)); } private void OnCreateNewQuote() => NavigationManager.NavigateTo("Quotes/QuoteAdd"); private Task OnSelectedTabChanged(string newSelectedTab) { selectedTab = newSelectedTab; return Task.CompletedTask; } }