57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
using System.Globalization;
|
|
using System.Security.Claims;
|
|
using Gremlin_BlazorServer.Data.EntityClasses;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
|
|
namespace Gremlin_BlazorServer.Pages.Quotes
|
|
{
|
|
public partial class QuoteIndex
|
|
{
|
|
[CascadingParameter]
|
|
private Task<AuthenticationState>? authenticationStateTask { get; set; }
|
|
|
|
private IList<Quote>? quotes;
|
|
private Quote? selectedQuote;
|
|
private readonly CultureInfo cultureInfo = new("de-DE");
|
|
private string selectedTab = "details";
|
|
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)
|
|
{
|
|
selectedQuote = _selectedQuote;
|
|
selectedQuote.Recipient = await genericController.GetAsync<Contact>(c => c.ContactId.Equals(selectedQuote.RecipientId));
|
|
if (selectedQuote.Recipient != null && selectedQuote != null)
|
|
{
|
|
selectedQuote = await genericController.GetAsync<Quote>(c => c.QuoteId.Equals(_selectedQuote.QuoteId), "Recipient", "LineItems");
|
|
selectedQuote.Recipient.Account = await genericController.GetAsync<Account>(a => a.AccountId.Equals(selectedQuote.Recipient.AccountId));
|
|
}
|
|
|
|
//selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.Quote.Equals(selectedQuote));
|
|
return;
|
|
}
|
|
|
|
private void OnCreateNewQuote()
|
|
{
|
|
navigationManager.NavigateTo("Quotes/QuoteAdd");
|
|
}
|
|
|
|
private Task OnSelectedTabChanged(string _selectedTab)
|
|
{
|
|
selectedTab = _selectedTab;
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
} |