add AuthorizeView to alle Pages

pull/1/head
DJh2o2 2023-01-18 10:51:22 +07:00
parent 2bc970ad13
commit 2a8852f7af
43 changed files with 441 additions and 1819 deletions

@ -57,12 +57,7 @@ namespace Gremlin_BlazorServer.Areas.Identity.Pages.Account
public async Task<IActionResult> OnGetAsync(string returnUrl = null)
{
// Ensure the user has gone through the username & password screen first
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
if (user == null)
{
throw new InvalidOperationException($"Unable to load two-factor authentication user.");
}
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync() ?? throw new InvalidOperationException($"Unable to load two-factor authentication user.");
ReturnUrl = returnUrl;
return Page();
@ -75,12 +70,7 @@ namespace Gremlin_BlazorServer.Areas.Identity.Pages.Account
return Page();
}
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
if (user == null)
{
throw new InvalidOperationException($"Unable to load two-factor authentication user.");
}
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync() ?? throw new InvalidOperationException($"Unable to load two-factor authentication user.");
string recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty);
Microsoft.AspNetCore.Identity.SignInResult result = await _signInManager.TwoFactorRecoveryCodeSignInAsync(recoveryCode);

@ -52,4 +52,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="img\" />
</ItemGroup>
</Project>

@ -3,41 +3,48 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject GenericTypeController<AccountType> AccountTypeService
@inject GenericController genericController;
<h1>AccountTypes</h1>
<DataGrid TItem="AccountType" Data="@accountTypes" SelectedRow="@selectedAccountType" SelectedRowChanged="@OnSelectedAccountTypeChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(AccountType.AccountTypeCode)" Caption="AccountTypeCode" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(AccountType.AccountTypeDescription)" Caption="AccountTypeDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(AccountType.DataStatus)" Caption="DataStatus" Filterable Sortable Editable/>
</DataGrid>
<AuthorizeView>
<Authorized>
<h1>AccountTypes</h1>
<DataGrid TItem="AccountType" Data="@accountTypes" SelectedRow="@selectedAccountType" SelectedRowChanged="@OnSelectedAccountTypeChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(AccountType.AccountTypeCode)" Caption="AccountTypeCode" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(AccountType.AccountTypeDescription)" Caption="AccountTypeDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(AccountType.DataStatus)" Caption="DataStatus" Filterable Sortable Editable/>
</DataGrid>
<h2>@selectedAccountType.AccountTypeCode: @selectedAccountType.AccountTypeDescription</h2>
<DataGrid TItem="Account" Data="@accountsOfSelectedAccountType" 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>
@if (selectedAccountType != null)
{
<h2>@selectedAccountType.AccountTypeCode: @selectedAccountType.AccountTypeDescription</h2>
<DataGrid TItem=" Account" Data="@accountsOfSelectedAccountType" 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>
}
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
List<AccountType> accountTypes = new();
AccountType selectedAccountType = new();
List<Account> accountsOfSelectedAccountType = new();
IList<AccountType>? accountTypes;
AccountType? selectedAccountType;
List<Account>? accountsOfSelectedAccountType;
protected override async Task OnInitializedAsync()
{
accountTypes = await Task.Run(() => AccountTypeService.GetAllAsync());
selectedAccountType = accountTypes.First();
}
protected override Task OnInitializedAsync()
{
accountTypes = genericController.GetAll<AccountType>("Accounts");
return Task.CompletedTask;
}
private async Task OnSelectedAccountTypeChanged(AccountType sAt)
{
selectedAccountType = sAt;
accountsOfSelectedAccountType = await AccountTypeService.GetAllAccountsAsync(selectedAccountType);
}
private void OnSelectedAccountTypeChanged(AccountType sAt) => selectedAccountType = sAt;
}

@ -0,0 +1,61 @@
@page "/Accounts"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject GenericController genericController
<AuthorizeView>
<Authorized>
<h1>Accounts</h1>
<DataGrid TItem="Account" Data="@accounts" SelectedRow="@selectedAccount" SelectedRowChanged="@OnSelectedAccountChanged" UseValidation Narrow 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/>
</DataGrid>
@if (selectedAccount != null)
{
<h2>Contacts in @selectedAccount.AccountName</h2>
<DataGrid TItem="Contact" Data="@selectedAccount.Contacts" UseValidation Narrow Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn/>
<DataGridColumn Field="@nameof(Contact.ContactId)" Caption="ContactId" 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/>
</DataGrid>
}
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
[CascadingParameter]
private Task<AuthenticationState>? authenticationStateTask { get; set; }
private IList<Account>? accounts;
private Account? selectedAccount;
protected override async Task OnInitializedAsync()
{
if (authenticationStateTask != null)
{
var user = (await authenticationStateTask).User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
accounts = genericController.GetAll<Account>();
}
}
}
private void OnSelectedAccountChanged(Account sA) => selectedAccount = sA;
}

@ -1,62 +0,0 @@
@page "/Accounts/AccountIndex"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject GenericController GenericController
<AuthorizeView>
<Authorized>
<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="@selectedAccount.Contacts" 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>
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
[CascadingParameter]
private Task<AuthenticationState>? authenticationStateTask { get; set; }
private IList<Account>? accounts;
private Account? selectedAccount;
protected override async Task OnInitializedAsync()
{
if (authenticationStateTask != null)
{
var user = (await authenticationStateTask).User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
accounts = GenericController.GetAll<Account>();
selectedAccount = accounts.First();
}
}
}
private void OnSelectedAccountChanged(Account sA) => selectedAccount = sA;
}

@ -1,64 +0,0 @@
@page "/Accounts/Add"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject AccountService AccountService
@inject NavigationManager NavigationManager
<h2>Add Account</h2>
<hr />
<form>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="SAPAccountNumber" class="control-label">SAPAccountNumber</label>
<input form="SAPAccountNumber" class="form-control" @bind="@account.SapAccountNumber" />
</div>
<div class="form-group">
<label for="AccountName" class="control-label">AccountName</label>
<input form="AccountName" class="form-control" @bind="@account.AccountName" />
</div>
<div class="form-group">
<label for="Street" class="control-label">Street</label>
<input form="Street" class="form-control" @bind="@account.Street" />
</div>
<div class="form-group">
<label for="ZIP" class="control-label">ZIP</label>
<input form="ZIP" class="form-control" @bind="@account.Zip" />
</div>
<div class="form-group">
<label for="City" class="control-label">City</label>
<input form="City" class="form-control" @bind="@account.City" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-primary" @onclick="@CreateAccount" value="Save"/>
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel"/>
</div>
</div>
</div>
</form>
@code {
Account account = new();
protected async void CreateAccount()
{
account.DataModificationByUser = "Gremlin_BlazorServer";
account.AccountType.AccountTypeCode = "SUP";
if (await AccountService.InsertAccountAsync(account))
{
NavigationManager.NavigateTo("Accounts/Index");
}
}
void Cancel() => NavigationManager.NavigateTo("Accounts/Index");
}

@ -1,66 +0,0 @@
@page "/Accounts/Delete/{AccountId}"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject AccountService AccountService
@inject NavigationManager NavigationManager
<h2>Delete Employee</h2>
<hr />
<h3>Are you sure want to delete this?</h3>
<form>
<div class="row">
<div class=" col-md-8">
<div class="form-group">
<label>AccountId:</label>
<label>@account.AccountId</label>
</div>
<div class="form-group">
<label>AccountName:</label>
<label>@account.AccountName</label>
</div>
<div class="form-group">
<label>Street:</label>
<label>@account.Street</label>
</div>
<div class="form-group">
<label>ZIP:</label>
<label>@account.Zip</label>
</div>
<div class="form-group">
<label>City:</label>
<label>@account.City</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-danger" @onclick="@DeleteAccount" value="Delete" />
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
</div>
</div>
</div>
</form>
@code {
[Parameter]
public string AccountId { get; set; } = default!;
Account account = new();
protected override async Task OnInitializedAsync()
{
account = await Task.Run(() => AccountService.GetAccountAsync(Convert.ToUInt32(AccountId)));
}
protected async void DeleteAccount()
{
await AccountService.DeleteAccountAsync(account);
NavigationManager.NavigateTo("Accounts/Index");
}
void Cancel()
{
NavigationManager.NavigateTo("Accounts/Index");
}
}

@ -1,70 +0,0 @@
@page "/Accounts/Edit/{AccountId}"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject AccountService AccountService
@inject NavigationManager NavigationManager
<h2>Edit Account</h2>
<hr />
<form>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="AccountId" class="control-label">AccountId</label>
<input form="AccountId" class="form-control" @bind="@account.AccountId" />
</div>
<div class="form-group">
<label for="SAPAccountNumber" class="control-label">SAPAccountNumber</label>
<input form="SAPAccountNumber" class="form-control" @bind="@account.SapAccountNumber" />
</div>
<div class="form-group">
<label for="AccountName" class="control-label">Name</label>
<input form="AccountName" class="form-control" @bind="@account.AccountName" />
</div>
<div class="form-group">
<label for="Street" class="control-label">Street</label>
<input form="Street" class="form-control" @bind="@account.Street" />
</div>
<div class="form-group">
<label for="ZIP" class="control-label">ZIP</label>
<input form="ZIP" class="form-control" @bind="@account.Zip" />
</div>
<div class="form-group">
<label for="City" class="control-label">City</label>
<input form="City" class="form-control" @bind="@account.City" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-primary" @onclick="@UpdateAccount" value="Update" />
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
</div>
</div>
</div>
</form>
@code {
[Parameter]
public string AccountId { get; set; } = string.Empty;
Account account = new();
protected override async Task OnInitializedAsync()
{
account = await Task.Run(() => AccountService.GetAccountAsync(Convert.ToUInt32(AccountId)));
}
protected async void UpdateAccount()
{
await AccountService.UpdateAccountAsync(account);
NavigationManager.NavigateTo("Accounts/Index");
}
void Cancel() => NavigationManager.NavigateTo("Accounts/Index");
}

@ -0,0 +1,87 @@
@page "/Contacts"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@using System.Globalization;
@inject GenericController genericController
<h1>Contacts</h1>
<AuthorizeView>
<Authorized>
<DataGrid TItem="Contact" Data="@contacts" SelectedRow="@selectedContact" SelectedRowChanged="@OnSelectedContactChanged" 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>
@if (selectedContact != null)
{
<h2>Quotes for SelectedContact: @selectedContact.FirstName @selectedContact.LastName</h2>
<DataGrid TItem=" Quote" Data="@selectedContact.Quotes" SelectedRow="@selectedQuote" SelectedRowChanged="@OnSelectedQuoteChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(Quote.QuoteId)" Caption="#" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuotationNumber)" Caption="QuotationNumber" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuotationDate)" Caption="Date" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.ValidUntil)" Caption="ValidUntil" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.TotalNet)" Caption="TotalNet" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.TotalGross)" Caption="TotalGross" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContains3Pp)" Caption="3PP" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContainsRb)" Caption="RB" Filterable Sortable/>
</DataGrid>
}
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@if (selectedQuote != null)
{
<h2>LineItems in SelectedQuote: @selectedQuote.QuotationNumber</h2>
<DataGrid TItem="LineItem" Data="@selectedQuote.LineItems" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(LineItem.Amount)" Caption="Amount" />
<DataGridColumn Field="@nameof(LineItem.ProductNumber)" Caption="ProductNumber" />
<DataGridColumn Field="@nameof(LineItem.OptionNumber)" Caption="OptionNumber" />
<DataGridColumn Field="@nameof(LineItem.ListPrice)" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Caption="ListPrice" />
<DataGridColumn Field="@nameof(LineItem.TotalDiscount)" Caption="TotalDiscount" DisplayFormat="{0.00%}." DisplayFormatProvider=cultureInfo />
<DataGridColumn Field="@nameof(LineItem.Total)" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Caption="Total" />
</DataGrid>
}
@code {
private IList<Contact>? contacts;
private Contact? selectedContact;
private Quote? selectedQuote;
private IList<Quote>? quotesOfSelectedContact;
private IList<LineItem>? lineItemsInSelectedQuote;
private readonly CultureInfo cultureInfo = new("de-DE");
protected override Task OnInitializedAsync()
{
contacts = genericController.GetAll<Contact>();
return base.OnInitializedAsync();
}
private Task OnSelectedContactChanged(Contact sC)
{
selectedContact = null;
quotesOfSelectedContact = genericController.GetAll<Quote>(q => q.Recipient == sC);
selectedContact = sC;
return Task.CompletedTask;
}
private Task OnSelectedQuoteChanged(Quote sQ)
{
selectedQuote = null;
lineItemsInSelectedQuote = genericController.GetAll<LineItem>(l => l.Quote == sQ);
selectedQuote = sQ;
return Task.CompletedTask;
}
}

@ -1,72 +0,0 @@
@page "/Contacts/Add"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject ContactService ContactService
@inject NavigationManager NavigationManager
@inject AccountService AccountService
<h2>Add Contact</h2>
<hr />
<form>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="ContactId" class="control-label">ContactId</label>
<input form="ContactId" class="form-control" @bind="@contact.ContactId" />
</div>
<div class="form-group">
<label for="AccountId" class="control-label">AccountId</label>
<input form="AccountId" class="form-control" @bind="@contact.AccountId" />
</div>
<div class="form-group">
<label for="LastName" class="control-label">LastName</label>
<input form="LastName" class="form-control" @bind="@contact.LastName" />
</div>
<div class="form-group">
<label for="FirstName" class="control-label">FirstName</label>
<input form="FirstName" class="form-control" @bind="@contact.FirstName" />
</div>
<div class="form-group">
<label for="Gender" class="control-label">Gender</label>
<input form="Gender" class="form-control" @bind="@contact.Gender" />
</div>
<div class="form-group">
<label for="EMail" class="control-label">EMail</label>
<input form="EMail" class="form-control" @bind="@contact.EMail" />
</div>
<div class="form-group">
<label for="SAPContactNumber" class="control-label">SAPContactNumber</label>
<input form="SAPContactNumber" class="form-control" @bind="@contact.SapContactNumber" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-primary" @onclick="@CreateContact" value="Save"/>
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel"/>
</div>
</div>
</div>
</form>
@code {
Contact contact = new();
protected async void CreateContact()
{
contact.DataModificationByUser = "Gremlin_BlazorServer";
//contact.DataStatus = "Active";
if (await ContactService.InsertContactAsync(contact))
{
NavigationManager.NavigateTo("Contacts/Index");
}
}
void Cancel() => NavigationManager.NavigateTo("Contacts/Index");
}

@ -1,80 +0,0 @@
@page "/Contacts/ContactIndex"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@using System.Globalization;
@inject GenericController genericController
<h1>Contacts</h1>
<DataGrid TItem="Contact" Data="@contacts" SelectedRow="@selectedContact" SelectedRowChanged="@OnSelectedContactChanged" 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>
@if (selectedContact != null)
{
<h2>Quotes for SelectedContact: @selectedContact.FirstName @selectedContact.LastName</h2>
<DataGrid TItem="Quote" Data="@selectedContact.Quotes" SelectedRow="@selectedQuote" SelectedRowChanged="@OnSelectedQuoteChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(Quote.QuoteId)" Caption="#" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuotationNumber)" Caption="QuotationNumber" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuotationDate)" Caption="Date" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.ValidUntil)" Caption="ValidUntil" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.TotalNet)" Caption="TotalNet" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.TotalGross)" Caption="TotalGross" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContains3Pp)" Caption="3PP" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContainsRb)" Caption="RB" Filterable Sortable/>
</DataGrid>
}
@if (selectedQuote != null)
{
<h2>LineItems in SelectedQuote: @selectedQuote.QuotationNumber</h2>
<DataGrid TItem="LineItem" Data="@selectedQuote.LineItems" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(LineItem.Amount)" Caption="Amount" />
<DataGridColumn Field="@nameof(LineItem.ProductNumber)" Caption="ProductNumber" />
<DataGridColumn Field="@nameof(LineItem.OptionNumber)" Caption="OptionNumber" />
<DataGridColumn Field="@nameof(LineItem.ListPrice)" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Caption="ListPrice" />
<DataGridColumn Field="@nameof(LineItem.TotalDiscount)" Caption="TotalDiscount" DisplayFormat="{0.00%}." DisplayFormatProvider=cultureInfo />
<DataGridColumn Field="@nameof(LineItem.Total)" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Caption="Total" />
</DataGrid>
}
@code {
private IList<Contact>? contacts;
private Contact? selectedContact;
private Quote? selectedQuote;
private IList<Quote>? quotesOfSelectedContact;
private IList<LineItem>? lineItemsInSelectedQuote;
private readonly CultureInfo cultureInfo = new("de-DE");
protected override Task OnInitializedAsync()
{
contacts = genericController.GetAll<Contact>();
return base.OnInitializedAsync();
}
private Task OnSelectedContactChanged(Contact sC)
{
selectedContact = null;
quotesOfSelectedContact = genericController.GetAll<Quote>(q => q.Recipient == sC);
selectedContact = sC;
return Task.CompletedTask;
}
private Task OnSelectedQuoteChanged(Quote sQ)
{
selectedQuote = null;
lineItemsInSelectedQuote = genericController.GetAll<LineItem>(l => l.Quote == sQ);
selectedQuote = sQ;
return Task.CompletedTask;
}
}

@ -1,74 +0,0 @@
@page "/Contacts/Delete/{ContactId}"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject ContactService ContactService
@inject NavigationManager NavigationManager
<h2>Delete Employee</h2>
<hr />
<h3>Are you sure want to delete this?</h3>
<form>
<div class="row">
<div class=" col-md-8">
<div class="form-group">
<label>ContactId:</label>
<label>@contact.ContactId</label>
</div>
<div class="form-group">
<label>ContactId:</label>
<label>@contact.ContactId</label>
</div>
<div class="form-group">
<label>LastName:</label>
<label>@contact.LastName</label>
</div>
<div class="form-group">
<label>FirstName:</label>
<label>@contact.FirstName</label>
</div>
<div class="form-group">
<label>Gender:</label>
<label>@contact.Gender</label>
</div>
<div class="form-group">
<label>EMail:</label>
<label>@contact.EMail</label>
</div>
<div class="form-group">
<label>SAPContactNumber:</label>
<label>@contact.SapContactNumber</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-danger" @onclick="@DeleteContact" value="Delete" />
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
</div>
</div>
</div>
</form>
@code {
[Parameter]
public string ContactId { get; set; } = default!;
Contact contact = new();
protected override async Task OnInitializedAsync()
{
contact = await Task.Run(() => ContactService.GetContactAsync(Convert.ToUInt32(ContactId)));
}
protected async void DeleteContact()
{
await ContactService.DeleteContactAsync(contact);
NavigationManager.NavigateTo("Contacts/Index");
}
void Cancel()
{
NavigationManager.NavigateTo("Contacts/Index");
}
}

@ -1,76 +0,0 @@
@page "/Contacts/Edit/{ContactId}"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject ContactService ContactService
@inject NavigationManager NavigationManager
<h2>Edit Contact</h2>
<hr />
<form>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="ContactId" class="control-label">ContactId</label>
<input form="ContactId" class="form-control" @bind="@contact.ContactId" />
</div>
<div class="form-group">
<label for="AccountId" class="control-label">AccountId</label>
<input form="AccountId" class="form-control" @bind="@contact.AccountId" />
</div>
<div class="form-group">
<label for="LastName" class="control-label">LastName</label>
<input form="LastName" class="form-control" @bind="@contact.LastName" />
</div>
<div class="form-group">
<label for="FirstName" class="control-label">FirstName</label>
<input form="FirstName" class="form-control" @bind="@contact.FirstName" />
</div>
<div class="form-group">
<label for="Gender" class="control-label">Gender</label>
<input form="Gender" class="form-control" @bind="@contact.Gender" />
</div>
<div class="form-group">
<label for="EMail" class="control-label">EMail</label>
<input form="EMail" class="form-control" @bind="@contact.EMail" />
</div>
<div class="form-group">
<label for="SAPContactNumber" class="control-label">SAPContactNumber</label>
<input form="SAPContactNumber" class="form-control" @bind="@contact.SapContactNumber" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-primary" @onclick="@UpdateContact" value="Update" />
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
</div>
</div>
</div>
</form>
@code {
[Parameter]
public string ContactId { get; set; } = string.Empty;
Contact contact = new();
protected override async Task OnInitializedAsync()
{
contact = await Task.Run(() => ContactService.GetContactAsync(Convert.ToUInt32(ContactId)));
}
protected async void UpdateContact()
{
contact.DataModificationByUser = "Gremlin_BlazorServer";
contact.DataModificationDate = DateTime.Now;
contact.DataVersionNumber++;
await ContactService.UpdateContactAsync(contact);
NavigationManager.NavigateTo("Contacts/Index");
}
void Cancel() => NavigationManager.NavigateTo("Contacts/Index");
}

@ -0,0 +1,45 @@
@page "/CustomDescriptions"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject GenericController genericController
<AuthorizeView>
<Authorized>
<h1>CustomDescriptions</h1>
<DataGrid TItem="CustomDescription" Data="@customDescriptions" SelectedRow="@selectedCustomDescription" SelectedRowChanged="@OnSelectedCustomDescriptionChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(CustomDescription.ProductNumber)" Caption="ProductNumber" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(CustomDescription.OptionNumber)" Caption="OptionNumber" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(CustomDescription.Heading)" Caption="Heading" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(CustomDescription.DescriptionText)" Caption="DescriptionText" Filterable Sortable Editable />
</DataGrid>
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
[CascadingParameter]
private Task<AuthenticationState>? authenticationStateTask { get; set; }
private IList<CustomDescription>? customDescriptions;
private CustomDescription? selectedCustomDescription;
protected override async Task OnInitializedAsync()
{
if (authenticationStateTask != null)
{
var user = (await authenticationStateTask).User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
customDescriptions = genericController.GetAll<CustomDescription>();
}
}
}
private void OnSelectedCustomDescriptionChanged(CustomDescription sCd) => selectedCustomDescription = sCd;
}

@ -1,62 +0,0 @@
@page "/CustomDescriptions/Add"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService CustomDescriptionService
@inject NavigationManager NavigationManager
<h2>Add CustomDescription</h2>
<hr />
<form>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="CustomDescriptionId" class="control-label">CustomDescriptionId</label>
<input form="CustomDescriptionId" class="form-control" @bind="@customDescription.CustomDescriptionId" />
</div>
<div class="form-group">
<label for="ProductNumber" class="control-label">ProductNumber</label>
<input form="ProductNumber" class="form-control" @bind="@customDescription.ProductNumber" />
</div>
<div class="form-group">
<label for="OptionNumber" class="control-label">OptionNumber</label>
<input form="OptionNumber" class="form-control" @bind="@customDescription.OptionNumber" />
</div>
<div class="form-group">
<label for="Heading" class="control-label">Heading</label>
<input form="Heading" class="form-control" @bind="@customDescription.Heading" />
</div>
<div class="form-group">
<label for="DescriptionText" class="control-label">DescriptionText</label>
<input form="DescriptionText" class="form-control" @bind="@customDescription.DescriptionText" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-primary" @onclick="@CreateCustomDescription" value="Save"/>
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel"/>
</div>
</div>
</div>
</form>
@code {
CustomDescription customDescription = new();
protected async void CreateCustomDescription()
{
customDescription.DataModificationByUser = "Gremlin_BlazorServer";
if (await CustomDescriptionService.InsertCustomDescriptionAsync(customDescription))
{
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
}
void Cancel() => NavigationManager.NavigateTo("CustomDescriptions/Index");
}

@ -1,66 +0,0 @@
@page "/CustomDescriptions/Delete/{CustomDescriptionId}"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService CustomDescriptionService
@inject NavigationManager NavigationManager
<h2>Delete Employee</h2>
<hr />
<h3>Are you sure want to delete this?</h3>
<form>
<div class="row">
<div class=" col-md-8">
<div class="form-group">
<label>CustomDescriptionId:</label>
<label>@customDescription!.CustomDescriptionId</label>
</div>
<div class="form-group">
<label>ProductNumber:</label>
<label>@customDescription.ProductNumber</label>
</div>
<div class="form-group">
<label>OptionNumber:</label>
<label>@customDescription.OptionNumber</label>
</div>
<div class="form-group">
<label>Heading:</label>
<label>@customDescription.Heading</label>
</div>
<div class="form-group">
<label>DescriptionText:</label>
<label>@customDescription.DescriptionText</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-danger" @onclick="@DeleteCustomDescription" value="Delete" />
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
</div>
</div>
</div>
</form>
@code {
[Parameter]
public string CustomDescriptionId { get; set; } = string.Empty;
CustomDescription customDescription = new();
protected override async Task OnInitializedAsync()
{
customDescription = await Task.Run(() => CustomDescriptionService.GetCustomDescriptionAsync(Convert.ToUInt32(CustomDescriptionId)));
}
protected async void DeleteCustomDescription()
{
await CustomDescriptionService.DeleteCustomDescriptionAsync(customDescription);
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
void Cancel()
{
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
}

@ -1,68 +0,0 @@
@page "/CustomDescriptions/Edit/{CustomDescriptionId}"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService CustomDescriptionservice
@inject NavigationManager NavigationManager
<h2>Edit CustomDescription</h2>
<hr />
<form>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="CustomDescriptionId" class="control-label">CustomDescriptionId</label>
<input form="CustomDescriptionId" class="form-control" @bind="@customDescription.CustomDescriptionId" />
</div>
<div class="form-group">
<label for="ProductNumber" class="control-label">ProductNumber</label>
<input form="ProductNumber" class="form-control" @bind="@customDescription.ProductNumber" />
</div>
<div class="form-group">
<label for="OptionNumber" class="control-label">OptionNumber</label>
<input form="OptionNumber" class="form-control" @bind="@customDescription.OptionNumber" />
</div>
<div class="form-group">
<label for="Heading" class="control-label">Heading</label>
<input form="Heading" class="form-control" @bind="@customDescription.Heading" />
</div>
<div class="form-group">
<label for="DescriptionText" class="control-label">DescriptionText</label>
<input form="DescriptionText" class="form-control" @bind="@customDescription.DescriptionText" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="button" class="btn btn-primary" @onclick="@UpdateCustomDescription" value="Update" />
<input type="button" class="btn btn-primary" @onclick="@Cancel" value="Cancel" />
</div>
</div>
</div>
</form>
@code {
[Parameter]
public string? CustomDescriptionId { get; set; }
CustomDescription customDescription = new();
protected override async Task OnInitializedAsync()
{
customDescription = await Task.Run(() => CustomDescriptionservice.GetCustomDescriptionAsync(Convert.ToUInt32(CustomDescriptionId)));
}
protected async void UpdateCustomDescription()
{
customDescription.DataModificationByUser = "Gremlin_BlazorServer";
customDescription.DataModificationDate = DateTime.Now;
customDescription.DataVersionNumber++;
await CustomDescriptionservice.UpdateCustomDescriptionAsync(customDescription);
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
void Cancel() => NavigationManager.NavigateTo("CustomDescriptions/Index");
}

@ -1,79 +0,0 @@
@page "/CustomDescriptions/Index"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService CustomDescriptionservice
<h1>CustomDescriptions</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="SearchCustomDescription"
@bind-value:event="oninput" placeholder="Search by ProductNumber"
@onchange="SearchCustomDescription_OnChange"/>
</div>
<NavLink class="nav-link" href="CustomDescriptions/Add">
<span class="oi oi-plus" aria-hidden="true">Add New CustomDescription</span>
</NavLink>
@if (allCustomDescriptions is null)
{
<p><em>Loading... !</em></p>
}
else
{
<p>Es wurden @filteredCustomDescriptions.Count CustomDescriptions gefunden.</p>
@if (allCustomDescriptions != null)
{
<table class="table">
<thead>
<tr>
<th>@nameof(CustomDescription.CustomDescriptionId)</th>
<th>@nameof(CustomDescription.ProductNumber)</th>
<th>@nameof(CustomDescription.OptionNumber)</th>
<th>@nameof(CustomDescription.Heading)</th>
<th>@nameof(CustomDescription.DescriptionText)</th>
</tr>
</thead>
<tbody>
@foreach (CustomDescription customDescription in filteredCustomDescriptions)
{<tr>
<td>@customDescription.CustomDescriptionId</td>
<td>@customDescription.ProductNumber</td>
<td>@customDescription.OptionNumber</td>
<td>@customDescription.Heading</td>
<td>@customDescription.DescriptionText</td>
<td>
<a class="nav-link" href="CustomDescriptions/Edit/@customDescription.CustomDescriptionId">
<span class="oi oi-pencil" aria-hidden="true">Edit</span>
</a>
<a class="nav-link" href="CustomDescriptions/Delete/@customDescription.CustomDescriptionId">
<span class="oi oi-trash" aria-hidden="true">Delete</span>
</a>
</td>
</tr>}
</tbody>
</table>
}
}
@code {
public string SearchCustomDescription = "";
List<CustomDescription> allCustomDescriptions = new();
List<CustomDescription> filteredCustomDescriptions = new();
protected override async Task OnInitializedAsync()
{
allCustomDescriptions = await Task.Run(() => CustomDescriptionservice.GetAllCustomDescriptionsAsync());
filteredCustomDescriptions = allCustomDescriptions;
}
private void SearchCustomDescription_OnChange()
{
filteredCustomDescriptions = allCustomDescriptions.Where(cD => cD.ProductNumber.ToLower().Contains(SearchCustomDescription.ToLower())).ToList();
}
}

@ -2,24 +2,16 @@
<PageTitle>Gremlin BlazorServer</PageTitle>
<h1>Gremlin BlazorServer</h1>
<h2>Welcome to new App!</h2>
<AuthorizeView>
<Authorized>
<h3>You are logged in as @context.User.Identity.Name</h3>
<p>You can only see this content if you're authorized.</p>
<button @onclick="SecureMethod">Check AuthSatus</button> @authStatus
@if(context != null && context.User != null && context.User.Identity != null)
{
<h3>You are logged in as @context.User.Identity.Name</h3>
}
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
string authStatus = "";
private void SecureMethod()
{
authStatus = "Authorized";
}
}
</AuthorizeView>

@ -0,0 +1,60 @@
@page "/LineItems"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@using System.Globalization;
@inject GenericController genericController
<AuthorizeView>
<Authorized>
<h1>LineItems</h1>
<DataGrid TItem="LineItem" Data="@lineItems" SelectedRow="@selectedLineItem" SelectedRowChanged="@OnSelectedLineItemChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(LineItem.LineItemId)" Caption="LineItemId" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.QuoteId)" Caption="QuoteId" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.Position)" Caption="Position" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.Amount)" Caption="Amount" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.ProductNumber)" Caption="LineItemId" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.OptionNumber)" Caption="QuoteId" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.SapShortDescription)" Caption="Position" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.SapLongDescription)" Caption="Amount" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.ProductLine)" Caption="ProductLine" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.TotalDiscount)" Caption="TotalDiscount" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.SalesDiscount)" Caption="SalesDiscount" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.PromotionalDiscount)" Caption="PromotionalDiscount" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.ContractualDiscount)" Caption="ContractualDiscount" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.DemoDiscount)" Caption="DemoDiscount" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.ListPrice)" Caption="ListPrice" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.ExtendedListPrice)" Caption="ExtendedListPrice" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.NetPrice)" Caption="NetPrice" Filterable Sortable Editable />
<DataGridColumn Field="@nameof(LineItem.Total)" Caption="Total" Filterable Sortable Editable />
</DataGrid>
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
[CascadingParameter]
private Task<AuthenticationState>? authenticationStateTask { get; set; }
private IList<LineItem>? lineItems;
private LineItem? selectedLineItem;
protected override async Task OnInitializedAsync()
{
if (authenticationStateTask != null)
{
var user = (await authenticationStateTask).User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
lineItems = genericController.GetAll<LineItem>();
}
}
}
private void OnSelectedLineItemChanged(LineItem sCd) => selectedLineItem = sCd;
}

@ -1,108 +0,0 @@
@page "/LineItems/Index"
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@using System.Globalization;
@inject LineItemService LineItemservice
<h1>LineItems</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="SearchLineItem"
@bind-value:event="oninput" placeholder="Search by ProductNumber"
@onchange="SearchLineItem_OnChange"/>
</div>
<NavLink class="nav-link" href="LineItems/Add">
<span class="oi oi-plus" aria-hidden="true">Add New LineItem</span>
</NavLink>
@if (allLineItems is null)
{
<p><em>Loading... !</em></p>
}
else
{
<p>Es wurden @filteredLineItems.Count LineItems gefunden.</p>
@if (allLineItems != null)
{
<table class="table">
<thead>
<tr>
<th>@nameof(LineItem.LineItemId)</th>
<th>@nameof(LineItem.QuoteId)</th>
<th>@nameof(LineItem.Position)</th>
<th>@nameof(LineItem.Amount)</th>
<th>@nameof(LineItem.ProductNumber)</th>
<th>@nameof(LineItem.OptionNumber)</th>
<th>@nameof(LineItem.SapShortDescription)</th>
<th>@nameof(LineItem.SapLongDescription)</th>
<th>@nameof(LineItem.ProductLine)</th>
<th>@nameof(LineItem.TotalDiscount)</th>
<th>@nameof(LineItem.SalesDiscount)</th>
<th>@nameof(LineItem.PromotionalDiscount)</th>
<th>@nameof(LineItem.ContractualDiscount)</th>
<th>@nameof(LineItem.DemoDiscount)</th>
<th>@nameof(LineItem.ListPrice)</th>
<th>@nameof(LineItem.ExtendedListPrice)</th>
<th>@nameof(LineItem.NetPrice)</th>
<th>@nameof(LineItem.Total)</th>
</tr>
</thead>
<tbody>
@foreach (LineItem lineItem in filteredLineItems)
{<tr>
<td>@lineItem.LineItemId</td>
<td>@lineItem.QuoteId</td>
<td>@lineItem.Position</td>
<td>@lineItem.Amount</td>
<td>@lineItem.ProductNumber</td>
<td>@lineItem.OptionNumber</td>
<td>@lineItem.SapShortDescription</td>
<td>@lineItem.SapLongDescription</td>
<td>@lineItem.ProductLine</td>
<td>@lineItem.TotalDiscount</td>
<td>@lineItem.SalesDiscount</td>
<td>@lineItem.SalesDiscount</td>
<td>@lineItem.PromotionalDiscount</td>
<td>@lineItem.ContractualDiscount</td>
<td>@lineItem.DemoDiscount</td>
<td>@lineItem.ListPrice.ToString("C", cultureInfo)</td>
<td>@lineItem.ExtendedListPrice.ToString("C", cultureInfo)</td>
<td>@lineItem.NetPrice.ToString("C", cultureInfo)</td>
<td>@lineItem.Total.ToString("C", cultureInfo)</td>
<td>
<a class="nav-link" href="LineItems/Edit/@lineItem.LineItemId">
<span class="oi oi-pencil" aria-hidden="true">Edit</span>
</a>
<a class="nav-link" href="LineItems/Delete/@lineItem.LineItemId">
<span class="oi oi-trash" aria-hidden="true">Delete</span>
</a>
</td>
</tr>}
</tbody>
</table>
}
}
@code {
public string SearchLineItem = "";
List<LineItem> allLineItems = new();
List<LineItem> filteredLineItems = new();
CultureInfo cultureInfo = new("de-DE");
protected override async Task OnInitializedAsync()
{
allLineItems = await Task.Run(() => LineItemservice.GetLineItemsAsync());
filteredLineItems = allLineItems;
}
private void SearchLineItem_OnChange()
{
filteredLineItems = allLineItems.Where(cD => cD.ProductNumber!.ToLower().Contains(SearchLineItem.ToLower())).ToList();
}
}

@ -3,41 +3,52 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject GenericController GenericController
@inject GenericController genericController
<h1>ProductLines</h1>
<DataGrid TItem="ProductLine" Data="@productLines" SelectedRow="@selectedProductLine" SelectedRowChanged="@OnSelectedProductLineChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(ProductLine.ProductLineCode)" Caption="ProductLineCode" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(ProductLine.ProductLineDescription)" Caption="ProductLineDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(ProductLine.DataStatus)" Caption="DataStatus" Filterable Sortable Editable/>
</DataGrid>
<AuthorizeView>
<Authorized>
<h1>ProductLines</h1>
<DataGrid TItem="ProductLine" Data="@productLines" SelectedRow="@selectedProductLine" SelectedRowChanged="@OnSelectedProductLineChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(ProductLine.ProductLineCode)" Caption="ProductLineCode" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(ProductLine.ProductLineDescription)" Caption="ProductLineDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(ProductLine.DataStatus)" Caption="DataStatus" Filterable Sortable Editable/>
</DataGrid>
<h2>@selectedProductLine.ProductLineCode: @selectedProductLine.ProductLineDescription</h2>
<DataGrid TItem="Product" Data="@productsOfSelectedProductLine" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(Product.ProductNumber)" Caption="ProductNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.OptionNumber)" Caption="OptionNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.SapShortDescription)" Caption="SapShortDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.SapLongDescription)" Caption="SapLongDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.ProductLine.ProductLineCode)" Caption="ProductLineCode" Filterable Sortable Editable/>
</DataGrid>
@if (selectedProductLine != null)
{
<h2>@selectedProductLine.ProductLineCode: @selectedProductLine.ProductLineDescription</h2>
<DataGrid TItem="Product" Data="@productsOfSelectedProductLine" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(Product.ProductNumber)" Caption="ProductNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.OptionNumber)" Caption="OptionNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.SapShortDescription)" Caption="SapShortDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.SapLongDescription)" Caption="SapLongDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.ProductLine.ProductLineCode)" Caption="ProductLineCode" Filterable Sortable Editable/>
</DataGrid>
}
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
private IList<ProductLine> productLines;
private ProductLine selectedProductLine;
private IList<Product> productsOfSelectedProductLine;
private IList<ProductLine>? productLines;
private ProductLine? selectedProductLine;
private IList<Product>? productsOfSelectedProductLine;
protected override async Task OnParametersSetAsync()
{
productLines = GenericController.GetAll<ProductLine>();
}
private Task OnSelectedProductLineChanged(ProductLine pL)
{
selectedProductLine = pL;
productsOfSelectedProductLine = GenericController.GetAll<Product>(product => product.ProductLine == selectedProductLine);
return Task.CompletedTask;
}
protected override Task OnParametersSetAsync()
{
productLines = genericController.GetAll<ProductLine>();
return Task.CompletedTask;
}
private Task OnSelectedProductLineChanged(ProductLine pL)
{
selectedProductLine = pL;
productsOfSelectedProductLine = genericController.GetAll<Product>(product => product.ProductLine == selectedProductLine);
return Task.CompletedTask;
}
}

@ -4,45 +4,53 @@
@using Gremlin_BlazorServer.Services;
@using System.Globalization
@inject GenericTypeController<Product> ProductService
<h1>Products</h1>
<DataGrid TItem="Product" Data="@products" SelectedRow="@selectedProduct" SelectedRowChanged="@OnSelectedProductChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(Product.ProductId)" Caption="ProductId" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.ProductNumber)" Caption="ProductNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.OptionNumber)" Caption="OptionNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.SapShortDescription)" Caption="SapShortDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.ProductLineCode)" Caption="ProductLineCode" Filterable Sortable Editable/>
</DataGrid>
<Column ColumnSize="ColumnSize.Is9">
<Fields>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">ProductNumber</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.ProductNumber"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">OptionNumber</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.OptionNumber"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">SapShortDescription</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.SapShortDescription"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">SapLongDescription</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.SapLongDescription"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Heading</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.CustomDescription.Heading"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">CoverletterText</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.CustomDescription.CoverletterText"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">DescriptionText</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.CustomDescription.DescriptionText"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Weight</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.Weight.ToString(CultureInfo.CurrentCulture)"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">ListPrice</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.ListPrice.ToString(CultureInfo.CurrentCulture)"/></FieldBody></Field>
</Fields>
</Column>
@inject GenericController genericController
<AuthorizeView>
<Authorized>
<h1>Products</h1>
<DataGrid TItem="Product" Data="@products" SelectedRow="@selectedProduct" SelectedRowChanged="@OnSelectedProductChanged" Editable ShowPager Bordered Hoverable Sortable Filterable Striped Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(Product.ProductId)" Caption="ProductId" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.ProductNumber)" Caption="ProductNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.OptionNumber)" Caption="OptionNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.SapShortDescription)" Caption="SapShortDescription" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Product.ProductLineCode)" Caption="ProductLineCode" Filterable Sortable Editable/>
</DataGrid>
@if (selectedProduct != null)
{
<Column ColumnSize=" ColumnSize.Is9">
<Fields>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">ProductNumber</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.ProductNumber"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">OptionNumber</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.OptionNumber"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">SapShortDescription</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.SapShortDescription"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">SapLongDescription</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.SapLongDescription"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">Heading</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.CustomDescription.Heading"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">CoverletterText</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.CustomDescription.CoverletterText"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">DescriptionText</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.CustomDescription.DescriptionText"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">Weight</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.Weight.ToString(CultureInfo.CurrentCulture)"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize=" ColumnSize.Is4">ListPrice</FieldLabel><FieldBody ColumnSize=" ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedProduct.ListPrice.ToString(CultureInfo.CurrentCulture)"/></FieldBody></Field>
</Fields>
</Column>
}
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>
<p>You're not signed in. Please click on the upper right to either register or log in.</p>
</NotAuthorized>
</AuthorizeView>
@code {
List<Product> products = new();
Product selectedProduct = new();
protected override async Task OnInitializedAsync()
{
products = await Task.Run(() => ProductService.GetAllAsync());
selectedProduct = products.First();
OnSelectedProductChanged(selectedProduct);
}
private void OnSelectedProductChanged(Product sP)
{
selectedProduct = sP;
}
IList<Product>? products;
Product? selectedProduct;
protected override Task OnInitializedAsync()
{
products = genericController.GetAll<Product>();
return Task.CompletedTask;
}
private void OnSelectedProductChanged(Product sP) => selectedProduct = sP;
}

@ -6,10 +6,6 @@
@using System.Diagnostics
@inject GenericController genericController
@inject GenericTypeController<Quote> QuoteService
@inject GenericTypeController<Contact> ContactService
@inject GenericTypeController<Account> AccountService
@inject GenericTypeController<CustomDescription> CustomDescriptionService
@inject QuoteHandling QuoteHandling
@inject NavigationManager navigationManager
@ -119,7 +115,7 @@
private async Task GenerateNewQuote(string salesRep)
{
quote.SalesRep = genericController.Get<Contact>(c => c.LastName == salesRep);
quote.QuoteId = await QuoteService.GetLastId() + 1;
quote.QuoteId = genericController.GetLast<Quote>().QuoteId + 1;
quote.QuotationNumber = quote.SalesRep.LastName switch
{
"Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{quote.QuoteId}",
@ -166,10 +162,13 @@
quote.Recipient = selectedContact;
}
private async void OnSave()
private Task OnSave()
{
quote.DataModificationByUser = "Gremlin_BlazorServer";
if (await QuoteService.InsertAsync(quote)) navigationManager.NavigateTo("Quotes/QuoteIndex");
if (genericController.Insert<Quote>(quote))
navigationManager.NavigateTo("Quotes/QuoteIndex");
return Task.CompletedTask;
}
private Task OnCreateTex()

@ -27,14 +27,10 @@
<DataGridColumn Field="@nameof(Quote.QuoteContainsRb)" Caption="RB" Filterable Sortable/>
</DataGrid>
}
else
{
<h3>Loading...</h3>
}
<h2>Quote Details</h2>
@if (selectedQuote != null)
{
<h2>Quote Details</h2>
<Row>
<Column ColumnSize="ColumnSize.Is4">
<Fields>
@ -85,15 +81,8 @@
<DataGridColumn Field="@nameof(LineItem.Total)" Caption="Total" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Editable />
</DataGrid>
}
else
{
<h3>Loading...</h3>
}
}
else
{
<h3>Loading...</h3>
}
</Authorized>
<NotAuthorized>
<h3>Authentication Failure!</h3>

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

@ -18,18 +18,7 @@ builder.Services.AddServerSideBlazor();
builder.Services.AddScoped<GremlinDb>();
builder.Services.AddScoped<GenericController>();
builder.Services.AddScoped<GenericTypeController<Contact>>();
builder.Services.AddScoped<GenericTypeController<Account>>();
builder.Services.AddScoped<GenericTypeController<AccountType>>();
builder.Services.AddScoped<GenericTypeController<ProductLine>>();
builder.Services.AddScoped<GenericTypeController<Product>>();
builder.Services.AddScoped<GenericTypeController<Quote>>();
builder.Services.AddScoped<GenericTypeController<CustomDescription>>();
builder.Services.AddScoped<QuoteHandling>();
builder.Services.AddScoped<LineItemService>();
builder.Services.AddScoped<ClipboardService>();
builder.Services.AddBlazorise(options => { options.Immediate = true; }).AddBootstrapProviders().AddFontAwesomeIcons();
builder.Services.AddOptions();

@ -0,0 +1,17 @@
# Part Number Opt PL Description Qty Price EUR Breaks EUR Uplift % Total Discount % Net EUR Total EUR Sales Discount YA9% Contractual Discount Y99% Promotion Discount Y07% Demo Discount Y04% PH Code PH Description YMax
1 G7104C 29 1260 Infinity II Flexible Pumpe 1 33344 0 0 40 20006.4 20006.4 40 0 0 0 ISL100P1 Pumps
2 G7104C 001 29 HPLC System Tool-Kit 1260 Infinity II 1 377 0 0 40 226.2 226.2 40 0 0 0
3 G7104C 004 29 Agilent Lab Advisor Advanced Software 1 1574 0 0 40 944.4 944.4 40 0 0 0
4 G7104C 034 29 InfinityLab Stay Safe Verschl., St.-Kit 1 664 0 0 40 398.4 398.4 40 0 0 0
5 G7104C 097 29 Poroshell 120 EC-C18 3,0x150mm, 2,7um 1 1 0 0 40 0.6 0.6 40 0 0 0
6 G7167A 29 1260 Infinity II Mehrfachprobengeber 1 27195 0 0 40 16317 16317 40 0 0 0 ISL100A1 Autosamplers
7 G7167A 060 29 Nutzung vorhandene Lizenz 1 -1733 0 0 40 -1039.8 -1039.8 40 0 0 0
8 G7167A 101 29 Agilent InfinityLab Proben-Thermostat 1 5871 0 0 40 3522.6 3522.6 40 0 0 0
9 G7116A 29 1260 Infinity II Therm. f. mehr. Saeulen 1 6275 0 0 40 3765 3765 40 0 0 0 ISL100LC1 LC Hardware
10 G7162A 29 1260 Infinity II Brechungsindexdetektor 1 13516 0 0 40 8109.6 8109.6 40 0 0 0 ISL100D1 Detectors
11 M8414AA LI OpenLab CDS Workstation PC-Paket 1 16854 0 0 40 10112.4 10112.4 40 0 0 0 ISF300F110 OpenLAB CDS w/Hardware
12 M8414AA 001 LI LC Geraeteverbindung 1 0 0 0 40 0 0 40 0 0 0
13 SYS-LC-1260II 74 LC 1260 Infinity II System 1 0 0 0 20 0 0 20 0 0 0 TSSYS0SYLC Service Systems - Liquid Chromatography
14 SYS-LC-1260II 2A9 74 Standard-Einweisung 1 999 0 0 20 799.2 799.2 20 0 0 0 TSSTRN Training Services
15 SYS-LC-1260II 8R2 74 CrossLab Silver - 2J, kompl. 1 10403 0 0 35 6761.95 6761.95 30 0 5 0 TSSYS2 Serviced As Systems - 2 YR > 29
1 # Part Number Opt PL Description Qty Price EUR Breaks EUR Uplift % Total Discount % Net EUR Total EUR Sales Discount YA9% Contractual Discount Y99% Promotion Discount Y07% Demo Discount Y04% PH Code PH Description YMax
2 1 G7104C 29 1260 Infinity II Flexible Pumpe 1 33344 0 0 40 20006.4 20006.4 40 0 0 0 ISL100P1 Pumps
3 2 G7104C 001 29 HPLC System Tool-Kit 1260 Infinity II 1 377 0 0 40 226.2 226.2 40 0 0 0
4 3 G7104C 004 29 Agilent Lab Advisor Advanced Software 1 1574 0 0 40 944.4 944.4 40 0 0 0
5 4 G7104C 034 29 InfinityLab Stay Safe Verschl., St.-Kit 1 664 0 0 40 398.4 398.4 40 0 0 0
6 5 G7104C 097 29 Poroshell 120 EC-C18 3,0x150mm, 2,7um 1 1 0 0 40 0.6 0.6 40 0 0 0
7 6 G7167A 29 1260 Infinity II Mehrfachprobengeber 1 27195 0 0 40 16317 16317 40 0 0 0 ISL100A1 Autosamplers
8 7 G7167A 060 29 Nutzung vorhandene Lizenz 1 -1733 0 0 40 -1039.8 -1039.8 40 0 0 0
9 8 G7167A 101 29 Agilent InfinityLab Proben-Thermostat 1 5871 0 0 40 3522.6 3522.6 40 0 0 0
10 9 G7116A 29 1260 Infinity II Therm. f. mehr. Saeulen 1 6275 0 0 40 3765 3765 40 0 0 0 ISL100LC1 LC Hardware
11 10 G7162A 29 1260 Infinity II Brechungsindexdetektor 1 13516 0 0 40 8109.6 8109.6 40 0 0 0 ISL100D1 Detectors
12 11 M8414AA LI OpenLab CDS Workstation PC-Paket 1 16854 0 0 40 10112.4 10112.4 40 0 0 0 ISF300F110 OpenLAB CDS w/Hardware
13 12 M8414AA 001 LI LC Geraeteverbindung 1 0 0 0 40 0 0 40 0 0 0
14 13 SYS-LC-1260II 74 LC 1260 Infinity II System 1 0 0 0 20 0 0 20 0 0 0 TSSYS0SYLC Service Systems - Liquid Chromatography
15 14 SYS-LC-1260II 2A9 74 Standard-Einweisung 1 999 0 0 20 799.2 799.2 20 0 0 0 TSSTRN Training Services
16 15 SYS-LC-1260II 8R2 74 CrossLab Silver - 2J, kompl. 1 10403 0 0 35 6761.95 6761.95 30 0 5 0 TSSYS2 Serviced As Systems - 2 YR > 29

@ -1,71 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class AccountService
{
private readonly GremlinDb gremlinDb;
public AccountService(GremlinDb gC)
{
gremlinDb = gC;
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<Account>> GetAllAccountsAsync()
{
return await gremlinDb.Accounts.ToListAsync();
}
public async Task<bool> InsertAccountAsync(Account account)
{
try
{
_ = await gremlinDb.Accounts.AddAsync(account);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<Account> GetAccountAsync(uint accountId)
{
Account account = new();
if (accountId != 0)
{
try
{
account = await gremlinDb.Accounts.FirstAsync(a => a.AccountId.Equals(accountId));
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
return account ?? new Account();
}
public async Task UpdateAccountAsync(Account account)
{
_ = gremlinDb.Accounts.Update(account);
_ = await gremlinDb.SaveChangesAsync();
}
public async Task DeleteAccountAsync(Account account)
{
_ = gremlinDb.Remove(account);
_ = await gremlinDb.SaveChangesAsync();
}
}
}

@ -1,60 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class AccountTypeService
{
private readonly GremlinDb gremlinDb;
public AccountTypeService(GremlinDb gC)
{
gremlinDb = gC;
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<AccountType>> GetAllAccountTypesAsync()
{
return await gremlinDb.AccountTypes.ToListAsync();
}
public async Task<bool> InsertAccountTypeAsync(AccountType accountType)
{
try
{
_ = await gremlinDb.AccountTypes.AddAsync(accountType);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<AccountType?> GetAccountTypeAsync(string accountTypeCode)
{
return await gremlinDb.AccountTypes.FirstOrDefaultAsync(accountType => accountType.AccountTypeCode.Equals(accountTypeCode));
}
public async Task<bool> UpdateAccountTypeAsync(AccountType accountType)
{
_ = gremlinDb.AccountTypes.Update(accountType);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteAccountTypeAsync(AccountType accountType)
{
_ = gremlinDb.Remove(accountType);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
}
}

@ -1,24 +0,0 @@
using Microsoft.JSInterop;
namespace Gremlin_BlazorServer.Services
{
public sealed class ClipboardService
{
private readonly IJSRuntime jsRuntime;
public ClipboardService(IJSRuntime jsRuntime)
{
this.jsRuntime = jsRuntime;
}
public ValueTask<string> ReadTextAsync()
{
return jsRuntime.InvokeAsync<string>("navigator.clipboard.readText");
}
public ValueTask WriteTextAsync(string text)
{
return jsRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text);
}
}
}

@ -1,70 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class ContactService
{
private static GremlinDb gremlinDb = new();
private readonly AccountService accountService = new(gremlinDb);
private readonly AccountTypeService accountTypeService = new(gremlinDb);
public ContactService(GremlinDb gC)
{
gremlinDb = gC;
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<Contact>> GetAllContactsAsync()
{
return await gremlinDb.Contacts.Include(c => c.Account).ToListAsync();
}
public async Task<bool> InsertContactAsync(Contact contact)
{
contact.Account = await accountService.GetAccountAsync(contact.AccountId);
contact.Account.AccountType = await accountTypeService.GetAccountTypeAsync("FPC") ?? new();
try
{
_ = await gremlinDb.Contacts.AddAsync(contact);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<Contact> GetContactAsync(uint contactId)
{
Contact? contact = await gremlinDb.Contacts.FirstOrDefaultAsync(c => c.ContactId.Equals(contactId));
return contact ?? new Contact();
}
public async Task<Contact> GetContactAsync(string lastName)
{
Contact? contact = await gremlinDb.Contacts.FirstOrDefaultAsync(c => c.LastName.Equals(lastName));
return contact ?? new Contact();
}
public async Task UpdateContactAsync(Contact contact)
{
_ = gremlinDb.Contacts.Update(contact);
_ = await gremlinDb.SaveChangesAsync();
}
public async Task DeleteContactAsync(Contact contact)
{
_ = gremlinDb.Remove(contact);
_ = await gremlinDb.SaveChangesAsync();
}
}
}

@ -1,76 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class CustomDescriptionService
{
private readonly GremlinDb gremlinDb;
public CustomDescriptionService(GremlinDb gC)
{
gremlinDb = gC;
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<CustomDescription>> GetAllCustomDescriptionsAsync()
{
return await gremlinDb.CustomDescriptions.ToListAsync();
}
public async Task<bool> InsertCustomDescriptionAsync(CustomDescription customDescription)
{
try
{
_ = await gremlinDb.CustomDescriptions.AddAsync(customDescription);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<CustomDescription> GetCustomDescriptionAsync(uint customDescriptionId)
{
return await gremlinDb.CustomDescriptions.FirstOrDefaultAsync(cD => cD.CustomDescriptionId.Equals(customDescriptionId)) ?? new CustomDescription();
}
public async Task<CustomDescription> GetCustomDescriptionAsync(string productNumber, string optionNumber)
{
CustomDescription? customDescription = await gremlinDb.CustomDescriptions.FirstOrDefaultAsync(cD => cD.ProductNumber == productNumber && cD.OptionNumber == optionNumber);
if (customDescription != null)
{
//Debug.WriteLine($"{productNumber}#{optionNumber}: {customDescription.DescriptionText}");
return customDescription;
}
else
{
Debug.WriteLine($"{productNumber}#{optionNumber}: keine CustomDescription gefunden!");
return new();
}
}
public async Task<bool> UpdateCustomDescriptionAsync(CustomDescription customDescription)
{
_ = gremlinDb.CustomDescriptions.Update(customDescription);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteCustomDescriptionAsync(CustomDescription customDescription)
{
_ = gremlinDb.Remove(customDescription);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
}
}

@ -37,5 +37,16 @@ namespace Gremlin_BlazorServer.Services
{
return gremlinDb.Set<TResult>().Include(include).AsEnumerable().FirstOrDefault(t => search(t));
}
public TResult? GetLast<TResult>() where TResult : class, IMetadata
{
return gremlinDb.Set<TResult>().AsEnumerable().Last();
}
public bool Insert<T>(T entity) where T : class, IMetadata
{
gremlinDb.Set<T>().Add(entity);
return (gremlinDb.SaveChanges() > 0);
}
}
}

@ -1,165 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
namespace Gremlin_BlazorServer.Services;
public class GenericTypeController<T> where T : class
{
private readonly GremlinDb gremlinDb = new();
public async Task<List<T>> GetAllAsync()
{
try
{
return await gremlinDb.Set<T>().ToListAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task<bool> InsertAsync(T entity)
{
try
{
_ = await gremlinDb.Set<T>().AddAsync(entity);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
public async Task UpdateAsync(T entity)
{
try
{
_ = gremlinDb.Set<T>().Update(entity);
_ = await gremlinDb.SaveChangesAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task DeleteAsync(T entity)
{
try
{
_ = gremlinDb.Set<T>().Remove(entity);
_ = await gremlinDb.SaveChangesAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task<List<Product>> GetAllProductsAsync(ProductLine productLine)
{
try
{
return await gremlinDb.Products.Where(p => p.ProductLine.Equals(productLine)).ToListAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task<List<Account>> GetAllAccountsAsync(AccountType accountType)
{
try
{
return await gremlinDb.Accounts.Where(a => a.AccountType.Equals(accountType)).ToListAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task<List<Contact>> GetAllContactsAsync(Account account)
{
try
{
return await gremlinDb.Contacts.Where(a => a.Account.Equals(account)).ToListAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
//public async Task<List<LineItem>> GetAllLineItemsAsync(Quote quote)
//{
// try
// {
// return await gremlinDb.LineItems.Where(a => a.Quote.Equals(quote)).ToListAsync();
// }
// catch (Exception e)
// {
// Console.WriteLine(e);
// throw;
// }
//}
public async Task<Account> GetAccountAsync(Contact contact)
{
try
{
Account result = await gremlinDb.Accounts.FirstAsync(a => a.AccountId.Equals(contact.AccountId));
return result;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task<Contact> GetContactAsync(string lastName)
{
try
{
return await gremlinDb.Contacts.FirstAsync(c => c.LastName.Equals(lastName));
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task<CustomDescription> GetCustomDescriptionAsync(LineItem lineItem)
{
try
{
return await gremlinDb.CustomDescriptions.FirstAsync(l => l.ProductNumber.Equals(lineItem.ProductNumber) && l.OptionNumber.Equals(lineItem.OptionNumber));
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public async Task<uint> GetLastId()
{
return await gremlinDb.Quotes.MaxAsync(q => q.QuoteId);
}
}

@ -1,113 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class LineItemService
{
private readonly GremlinDb gremlinDb;
public LineItemService(GremlinDb gC)
{
gremlinDb = gC;
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<LineItem>> GetLineItemsAsync()
{
return await gremlinDb.LineItems.ToListAsync();
}
public async Task<bool> InsertLineItemAsync(LineItem lineItem)
{
try
{
_ = await gremlinDb.LineItems.AddAsync(lineItem);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<LineItem?> GetLineItemAsync(uint lineItemId)
{
return await gremlinDb.LineItems.FirstOrDefaultAsync(lineItem => lineItem.LineItemId.Equals(lineItemId));
}
public async Task<bool> UpdateLineItemAsync(LineItem lineItem)
{
_ = gremlinDb.LineItems.Update(lineItem);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteLineItemAsync(LineItem lineItem)
{
_ = gremlinDb.Remove(lineItem);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public static List<LineItem> ReadLineItemsFromClipboard(string clipboard)
{
if (clipboard != "")
{
List<LineItem> lineItems = new();
//Zeilen aufteilen
IEnumerable<string> clipboardLines = clipboard.Split(Environment.NewLine.ToCharArray());
List<string[]> lineItemStrings = (from clipboardLine in clipboardLines where clipboardLine != "" select clipboardLine.Split('\t')).ToList();
foreach (string[] lineItemString in lineItemStrings)
{
//Anzahl an Spalten entspricht Clipboard
if (lineItemString.Length == 19)
{
//Header ignorieren
if (lineItemString[0] == "#") { continue; }
//Dateiinhalt in Klasse schreiben
LineItem lineItem = new()
{
Position = ushort.Parse(lineItemString[0]),
ProductNumber = lineItemString[1],
OptionNumber = lineItemString[2],
ProductLine = lineItemString[3],
SapShortDescription = lineItemString[4],
Amount = ushort.Parse(lineItemString[5]),
ListPrice = decimal.Parse(lineItemString[6]),
TotalDiscount = decimal.Parse(lineItemString[9]),
NetPrice = decimal.Parse(lineItemString[10]),
Total = decimal.Parse(lineItemString[11]),
SalesDiscount = decimal.Parse(lineItemString[12]),
ContractualDiscount = decimal.Parse(lineItemString[13]),
PromotionalDiscount = decimal.Parse(lineItemString[14]),
DemoDiscount = decimal.Parse(lineItemString[15])
};
//Preise selbst berechnen
//lineItem.CalcNetPrice = lineItem.ListPrice * (100 - lineItem.TotalDiscount) / 100;
//lineItem.CalcTotalNet = lineItem.CalcNetPrice * lineItem.Amount;
//lineItem.CustomDescriptionVM = CustomDescriptionViewModel.GetCustomDescription(lineItem);
lineItems.Add(lineItem);
}
}
return lineItems;
}
return new();
}
}
}

@ -1,60 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class ProductLineService
{
private readonly GremlinDb gremlinDb;
public ProductLineService(GremlinDb gC)
{
gremlinDb = gC;
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<ProductLine>> GetAllProductLinesAsync()
{
return await gremlinDb.ProductLines.ToListAsync();
}
public async Task<bool> InsertProductLineAsync(ProductLine productLine)
{
try
{
_ = await gremlinDb.ProductLines.AddAsync(productLine);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<ProductLine?> GetProductLineAsync(string productLineCode)
{
return await gremlinDb.ProductLines.FirstOrDefaultAsync(productLine => productLine.ProductLineCode.Equals(productLineCode));
}
public async Task<bool> UpdateProductLineAsync(ProductLine productLine)
{
_ = gremlinDb.ProductLines.Update(productLine);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteProductLineAsync(ProductLine productLine)
{
_ = gremlinDb.Remove(productLine);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
}
}

@ -1,61 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class ProductService
{
private readonly GremlinDb gremlinDb;
public ProductService(GremlinDb gC)
{
gremlinDb = gC;
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<Product>> GetAllProductsAsync()
{
return await gremlinDb.Products.ToListAsync();
}
public async Task<bool> InsertProductAsync(Product product)
{
try
{
_ = await gremlinDb.Products.AddAsync(product);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<Product> GetProductAsync(string productNumber)
{
Product? product = await gremlinDb.Products.FirstOrDefaultAsync(product => product.ProductNumber.Equals(productNumber));
return product ?? new();
}
public async Task<bool> UpdateProductAsync(Product product)
{
_ = gremlinDb.Products.Update(product);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteProductAsync(Product product)
{
_ = gremlinDb.Remove(product);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
}
}

@ -7,8 +7,6 @@ namespace Gremlin_BlazorServer.Services
public class TexService
{
private readonly GenericController genericController = new();
private readonly GenericTypeController<Account> accountService = new();
private readonly GenericTypeController<CustomDescription> customDescriptionService = new();
public StringBuilder CreateTex(Quote quote)
{

@ -16,30 +16,26 @@
</div>
<AuthorizeView>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Contacts/ContactIndex">
<NavLink class="nav-link" href="Contacts">
<span class="oi oi-target" aria-hidden="true"></span>Contacts
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Accounts/AccountIndex">
<NavLink class="nav-link" href="Accounts">
<span class="oi oi-star" aria-hidden="true"></span>Accounts
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="CustomDescriptions/Index">
<NavLink class="nav-link" href="CustomDescriptions">
<span class="oi oi-spreadsheet" aria-hidden="true"></span>CustomDescriptions
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="LineItems/Index">
<NavLink class="nav-link" href="LineItems">
<span class="oi oi-task" aria-hidden="true"></span>LineItems
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Quotes/QuoteIndex">
<span class="oi oi-terminal" aria-hidden="true"></span>Quotes
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Products">
<span class="oi oi-box" aria-hidden="true"></span>Products
@ -54,7 +50,12 @@
<NavLink class="nav-link" href="AccountTypes">
<span class="oi oi-bell" aria-hidden="true"></span>AccountTypes
</NavLink>
</div>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Quotes/QuoteIndex">
<span class="oi oi-terminal" aria-hidden="true"></span>Quotes
</NavLink>
</div>
</AuthorizeView>
</nav>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB