45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
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<Quote>? quotes;
|
|
private Quote? selectedQuote;
|
|
private string selectedTab = "details";
|
|
|
|
[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 }) quotes = await GenericController.GetAllAsync<Quote>();
|
|
}
|
|
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async Task OnSelectedQuoteChanged(Quote selectedQuote) {
|
|
this.selectedQuote = selectedQuote;
|
|
this.selectedQuote.Recipient = GenericController.Get<Contact>(c => c.ContactId.Equals(this.selectedQuote.RecipientId));
|
|
if (this.selectedQuote.Recipient != null && this.selectedQuote != null) {
|
|
this.selectedQuote = await GenericController.Get<Quote>(c => c.QuoteId.Equals(selectedQuote.QuoteId), "Recipient", "LineItems");
|
|
this.selectedQuote.Recipient.Account = GenericController.Get<Account>(a => a.AccountId.Equals(this.selectedQuote.Recipient.AccountId));
|
|
}
|
|
|
|
//selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.Quote.Equals(selectedQuote));
|
|
}
|
|
|
|
private void OnCreateNewQuote() => NavigationManager.NavigateTo("Quotes/QuoteAdd");
|
|
|
|
private Task OnSelectedTabChanged(string newSelectedTab) {
|
|
selectedTab = newSelectedTab;
|
|
return Task.CompletedTask;
|
|
}
|
|
} |