refactoring of AccountTypes, Accounts, Contacts, Products and ProductLines
parent
4c90bf6559
commit
d43c22917e
@ -0,0 +1,46 @@
|
||||
@page "/Accounts/AccountIndex"
|
||||
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
@inject ControllerService<Account> AccountService
|
||||
|
||||
<h1>Accounts</h1>
|
||||
<DataGrid TItem="Account" Data="@accounts" SelectedRow="@selectedAccount" SelectedRowChanged="@OnSelectedAccountChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
|
||||
<DataGridCommandColumn />
|
||||
<DataGridColumn Field="@nameof(Account.AccountId)" Caption="AccountId" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Account.AccountName)" Caption="AccountName" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Account.Street)" Caption="Street" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Account.Zip)" Caption="Zip" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Account.City)" Caption="City" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Account.SapAccountNumber)" Caption="SapAccountNumber" Filterable Sortable Editable/>
|
||||
</DataGrid>
|
||||
<h2>Contacts in @selectedAccount.AccountName</h2>
|
||||
<DataGrid TItem="Contact" Data="@contactsInSelectedAccount" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
|
||||
<DataGridCommandColumn />
|
||||
<DataGridColumn Field="@nameof(Contact.ContactId)" Caption="ContactId" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Contact.AccountId)" Caption="AccountId" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Contact.LastName)" Caption="LastName" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Contact.FirstName)" Caption="FirstName" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Contact.Gender)" Caption="Gender" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Contact.EMail)" Caption="EMail" Filterable Sortable Editable/>
|
||||
<DataGridColumn Field="@nameof(Contact.SapContactNumber)" Caption="SAPContactNumber" Filterable Sortable Editable/>
|
||||
</DataGrid>
|
||||
|
||||
@code {
|
||||
List<Account> accounts = new();
|
||||
Account selectedAccount = new();
|
||||
List<Contact> contactsInSelectedAccount = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
accounts = await Task.Run(() => AccountService.GetAllAsync());
|
||||
selectedAccount = accounts.First();
|
||||
}
|
||||
|
||||
private async Task OnSelectedAccountChanged(Account sA)
|
||||
{
|
||||
selectedAccount = sA;
|
||||
contactsInSelectedAccount = await AccountService.GetAllContactsAsync(selectedAccount);
|
||||
}
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
@page "/Accounts/Index"
|
||||
|
||||
@using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
@using Gremlin_BlazorServer.Services;
|
||||
|
||||
@inject AccountService AccountService
|
||||
|
||||
<h1>Accounts</h1>
|
||||
|
||||
<div class="text-center bg-blue-100">
|
||||
<input class="border-4 w-1/3 rounded m-6 p-6 h-8
|
||||
border-blue-300" @bind-value="SearchAccount"
|
||||
@bind-value:event="oninput" placeholder="Search by AccountName"
|
||||
@onchange="SearchAccount_OnChange"/>
|
||||
</div>
|
||||
|
||||
<NavLink class="nav-link" href="Accounts/Add">
|
||||
<span class="oi oi-plus" aria-hidden="true">Add New Account</span>
|
||||
</NavLink>
|
||||
|
||||
|
||||
@if (allAccounts is null)
|
||||
{
|
||||
<p><em>Loading... !</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Es wurden @filteredAccounts.Count Accounts gefunden.</p>
|
||||
@if (allAccounts != null)
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@nameof(Account.AccountId)</th>
|
||||
<th>@nameof(Account.AccountName)</th>
|
||||
<th>@nameof(Account.Street)</th>
|
||||
<th>@nameof(Account.Zip)</th>
|
||||
<th>@nameof(Account.City)</th>
|
||||
<th>@nameof(Account.SapAccountNumber)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (Account account in filteredAccounts)
|
||||
{<tr>
|
||||
<td>@account.AccountId</td>
|
||||
<td>@account.AccountName</td>
|
||||
<td>@account.Street</td>
|
||||
<td>@account.Zip</td>
|
||||
<td>@account.City</td>
|
||||
<td>@account.SapAccountNumber</td>
|
||||
<td>
|
||||
<a class="nav-link" href="Accounts/Edit/@account.AccountId">
|
||||
<span class="oi oi-pencil" aria-hidden="true">Edit</span>
|
||||
</a>
|
||||
<a class="nav-link" href="Accounts/Delete/@account.AccountId">
|
||||
<span class="oi oi-trash" aria-hidden="true">Delete</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
public string SearchAccount = "";
|
||||
List<Account> allAccounts = new();
|
||||
List<Account> filteredAccounts = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
allAccounts = await Task.Run(() => AccountService.GetAllAccountsAsync());
|
||||
filteredAccounts = allAccounts;
|
||||
}
|
||||
|
||||
private void SearchAccount_OnChange()
|
||||
{
|
||||
filteredAccounts = allAccounts.Where(a => a.AccountName.ToLower().Contains(SearchAccount.ToLower())).ToList();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue