Quote Creation

pull/3/head
DJh2o2 2023-08-09 15:21:20 +07:00
parent 6d12195948
commit a6f8e447b0
5 changed files with 129 additions and 36 deletions

@ -0,0 +1,53 @@
@page "/Quotes/QuoteCreate"
@using Gremlin_BlazorServer.Data.EntityClasses
<AuthorizeView>
<Authorized>
<Div Margin="Margin.Is3"
Border="Border.Dark.OnAll"
Padding="Padding.Is3"
style="box-shadow: 10px 10px #343A40">
<Heading Size="HeadingSize.Is4">Quote Creation</Heading>
<Paragraph>
<Fields>
<Field>
<FieldLabel>ProductNumber</FieldLabel>
<TextEdit Text="@productNumber" TextChanged="@OnSearchChanged"/>
</Field>
<Field>
<FieldLabel>OptionNumber</FieldLabel>
<TextEdit>
<TextEdit Text="@optionNumber" TextChanged="@OnSearchChanged"/>
</TextEdit>
</Field>
</Fields>
</Paragraph>
<Paragraph>
<DataGrid TItem="Product" Data="@foundProducts" SelectedRow="@selectedProduct" SelectedRowChanged="@OnSelectedProductChanged" Narrow FixedHeader ShowPager Bordered Hoverable Sortable Striped Responsive>
<DataGridColumns>
<DataGridColumn Field="@nameof(Product.ProductId)" Caption="ProductId" Sortable/>
<DataGridColumn Field="@nameof(Product.ProductNumber)" Caption="ProductNumber" Sortable/>
<DataGridColumn Field="@nameof(Product.OptionNumber)" Caption="OptionNumber" Sortable/>
<DataGridColumn Field="@nameof(Product.SapShortDescription)" Caption="SapShortDescription" Sortable/>
<DataGridColumn Field="@nameof(Product.SapLongDescription)" Caption="SapLongDescription" Sortable/>
<DataGridColumn Field="@nameof(Product.Weight)" Caption="Weight" DisplayFormat="{0:n2} kg" Sortable/>
<DataGridColumn Field="@nameof(Product.ListPrice)" Caption="ListPrice" DisplayFormat="{0:C}" Sortable/>
<DataGridColumn Field="@nameof(Product.ProductLineCode)" Caption="ProductLineCode" Sortable/>
</DataGridColumns>
</DataGrid>
</Paragraph>
</Div>
</Authorized>
<NotAuthorized>
<Div Margin="Margin.Is3"
Border="Border.Dark.OnAll"
Padding="Padding.Is3"
style="box-shadow: 10px 10px #343A40">
<Heading Size="HeadingSize.Is3">Authentication Failure!</Heading>
<Paragraph>You're not signed in. Please click on the upper right to either register or log in.</Paragraph>
</Div>
</NotAuthorized>
</AuthorizeView>

@ -0,0 +1,31 @@
using System.Security.Claims;
using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace Gremlin_BlazorServer.Pages.Quotes;
public partial class QuoteCreate {
private IList<Product>? foundProducts;
private IList<LineItem>? lineItems;
private string optionNumber = "";
private string productNumber = "";
private Product selectedProduct;
[CascadingParameter] private Task<AuthenticationState>? AuthenticationStateTask { get; set; }
protected override async Task OnInitializedAsync() {
if (AuthenticationStateTask != null) {
ClaimsPrincipal user = (await AuthenticationStateTask).User;
if (user.Identity is { IsAuthenticated: true }) {
// quotes = await GenericController.GetAllAsync<Quote>();
}
}
await base.OnInitializedAsync();
}
private async Task OnSearchChanged() => foundProducts = await GenericController.GetAllAsync<Product>(p => p.ProductNumber.Contains(productNumber) && p.OptionNumber.Contains(optionNumber));
private void OnSelectedProductChanged(Product product) => selectedProduct = product;
}

@ -8,40 +8,38 @@ using Microsoft.AspNetCore.Components.Authorization;
namespace Gremlin_BlazorServer.Pages.Quotes; namespace Gremlin_BlazorServer.Pages.Quotes;
public partial class QuoteIndex { public partial class QuoteIndex {
private readonly CultureInfo cultureInfo = new("de-DE"); private readonly CultureInfo cultureInfo = new("de-DE");
private IList<Quote>? quotes; private IList<Quote>? quotes;
private Quote? selectedQuote; private Quote? selectedQuote;
private string selectedTab = "details"; private string selectedTab = "details";
[CascadingParameter] private Task<AuthenticationState>? AuthenticationStateTask { get; set; } [CascadingParameter] private Task<AuthenticationState>? AuthenticationStateTask { get; set; }
protected override async Task OnInitializedAsync() { protected override async Task OnInitializedAsync() {
if (AuthenticationStateTask != null) { if (AuthenticationStateTask != null) {
ClaimsPrincipal user = (await AuthenticationStateTask).User; ClaimsPrincipal user = (await AuthenticationStateTask).User;
if (user.Identity is { IsAuthenticated: true }) quotes = await GenericController.GetAllAsync<Quote>(); if (user.Identity is { IsAuthenticated: true }) quotes = await GenericController.GetAllAsync<Quote>();
} }
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
private async Task OnSelectedQuoteChanged(Quote selectedQuote) { private async Task OnSelectedQuoteChanged(Quote selectedQuote) {
this.selectedQuote = selectedQuote; this.selectedQuote = selectedQuote;
this.selectedQuote.Recipient = GenericController.Get<Contact>(c => c.ContactId.Equals(this.selectedQuote.RecipientId)); this.selectedQuote.Recipient = GenericController.Get<Contact>(c => c.ContactId.Equals(this.selectedQuote.RecipientId));
if (this.selectedQuote.Recipient != null && this.selectedQuote != null) { if (this.selectedQuote.Recipient != null && this.selectedQuote != null) {
this.selectedQuote = await GenericController.Get<Quote>(c => c.QuoteId.Equals(selectedQuote.QuoteId), "Recipient", "LineItems"); this.selectedQuote = await GenericController.Get<Quote>(c => c.QuoteId.Equals(selectedQuote.QuoteId), "Recipient", "LineItems");
this.selectedQuote.Recipient.Account = GenericController.Get<Account>(a => a.AccountId.Equals(this.selectedQuote.Recipient.AccountId)); this.selectedQuote.Recipient.Account = GenericController.Get<Account>(a => a.AccountId.Equals(this.selectedQuote.Recipient.AccountId));
} }
//selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.Quote.Equals(selectedQuote)); //selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.Quote.Equals(selectedQuote));
} }
private void OnCreateNewQuote() { private void OnCreateNewQuote() => NavigationManager.NavigateTo("Quotes/QuoteAdd");
NavigationManager.NavigateTo("Quotes/QuoteAdd");
} private Task OnSelectedTabChanged(string newSelectedTab) {
selectedTab = newSelectedTab;
private Task OnSelectedTabChanged(string selectedTab) { return Task.CompletedTask;
this.selectedTab = selectedTab; }
return Task.CompletedTask;
}
} }

@ -56,6 +56,12 @@
Add Add
</BarLink> </BarLink>
</BarDropdownItem> </BarDropdownItem>
<BarDropdownItem>
<BarLink To="/Quotes/QuoteCreate">
<BarIcon IconName="IconName.Subscript"/>
Create
</BarLink>
</BarDropdownItem>
</BarDropdownMenu> </BarDropdownMenu>
</BarDropdown> </BarDropdown>
</BarItem> </BarItem>

@ -64,6 +64,11 @@
<span class="oi oi-plus" aria-hidden="true"></span>Add Quote <span class="oi oi-plus" aria-hidden="true"></span>Add Quote
</NavLink> </NavLink>
</div> </div>
<div class="nav-item px-2">
<NavLink class="nav-link" href="Quotes/QuoteNew">
<span class="oi oi-plus" aria-hidden="true"></span>Quote Creation
</NavLink>
</div>
</div> </div>
</AuthorizeView> </AuthorizeView>
</nav> </nav>