@page "/Accounts" @using Gremlin_BlazorServer.Services @using Gremlin_BlazorServer.Data.EntityClasses @using System.Security.Claims @using System.Text; @inject GenericController genericController @inject GenericImporter genericImporter Accounts Import Accounts @*Import Accounts*@ @context.LocalizationString @context.LocalizationString New Edit Delete Clear Filter @if (selectedAccount != null) { Contacts in @selectedAccount.AccountName } Authentication Failure! You're not signed in. Please click on the upper right to either register or log in. @code { [CascadingParameter] private Task? authenticationStateTask { get; set; } private IList? accounts; private Account? selectedAccount; private bool isImportingAccounts; protected override async Task OnInitializedAsync() { if (authenticationStateTask != null) { ClaimsPrincipal user = (await authenticationStateTask).User; if (user.Identity is {IsAuthenticated: true }) { accounts = genericController.GetAll(); } } } private void OnSelectedAccountChanged(Account sA) { selectedAccount = sA; selectedAccount.Contacts = genericController.GetAll(c => c.AccountId == selectedAccount.AccountId); } private async Task OnImportAccounts(FileChangedEventArgs fileChangedEventArgs) { isImportingAccounts = true; try { foreach (IFileEntry? file in fileChangedEventArgs.Files) { using MemoryStream stream = new(); await file.WriteToStreamAsync(stream); stream.Seek(0, SeekOrigin.Begin); using StreamReader reader = new(stream); string fileContent = await reader.ReadToEndAsync(); bool success = await genericImporter.ImportCsvAsync(fileContent); } } catch (Exception exception) { Console.WriteLine(exception.Message); } Console.WriteLine("Account import successfull"); isImportingAccounts = false; StateHasChanged(); return; } }
You're not signed in. Please click on the upper right to either register or log in.