refactoring of EntityConfig to avoid new generation of items
parent
884a17c428
commit
ab95729a4a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,106 +1,124 @@
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
using Blazorise;
|
||||
using Blazorise.DataGrid;
|
||||
using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Gremlin_BlazorServer.Pages;
|
||||
|
||||
public partial class Contacts {
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState>? authenticationStateTask { get; set; }
|
||||
public partial class Contacts
|
||||
{
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState>? authenticationStateTask { get; set; }
|
||||
|
||||
private IList<Contact>? contacts;
|
||||
private Contact? selectedContact;
|
||||
private readonly List<Contact>? selectedContacts;
|
||||
private Quote? selectedQuote;
|
||||
private readonly CultureInfo cultureInfo = new("de-DE");
|
||||
private readonly int totalContacts;
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (authenticationStateTask != null)
|
||||
{
|
||||
ClaimsPrincipal user = (await authenticationStateTask).User;
|
||||
if (user.Identity is { IsAuthenticated: true })
|
||||
{
|
||||
contacts = await genericController.GetAllAsync<Contact>();
|
||||
}
|
||||
}
|
||||
|
||||
private IList<Contact>? contacts;
|
||||
private Contact? selectedContact;
|
||||
private readonly List<Contact>? selectedContacts;
|
||||
private Quote? selectedQuote;
|
||||
private readonly CultureInfo cultureInfo = new("de-DE");
|
||||
private readonly int totalContacts;
|
||||
protected override async Task OnInitializedAsync() {
|
||||
if (authenticationStateTask != null) {
|
||||
ClaimsPrincipal user = (await authenticationStateTask).User;
|
||||
if (user.Identity is { IsAuthenticated: true }) {
|
||||
contacts = await genericController.GetAllAsync<Contact>();
|
||||
}
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
private async Task OnSelectedContactChanged(Contact _selectedContact)
|
||||
{
|
||||
if (_selectedContact != null)
|
||||
{
|
||||
selectedContact = _selectedContact;
|
||||
selectedContact.Quotes = await genericController.GetAllAsync<Quote>(q => q.RecipientId.Equals(selectedContact.ContactId));
|
||||
}
|
||||
|
||||
private async Task OnSelectedContactChanged(Contact _selectedContact) {
|
||||
if (_selectedContact != null) {
|
||||
selectedContact = _selectedContact;
|
||||
selectedContact.Quotes = await genericController.GetAllAsync<Quote>(q => q.ContactId.Equals(selectedContact.ContactId));
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
private async Task OnSelectedQuoteChanged(Quote _selectedQuote)
|
||||
{
|
||||
if (_selectedQuote != null)
|
||||
{
|
||||
selectedQuote = _selectedQuote;
|
||||
selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.QuoteId.Equals(selectedQuote.QuoteId));
|
||||
}
|
||||
|
||||
private async Task OnSelectedQuoteChanged(Quote _selectedQuote) {
|
||||
if (_selectedQuote != null) {
|
||||
selectedQuote = _selectedQuote;
|
||||
selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.QuoteId.Equals(selectedQuote.QuoteId));
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
private async Task OnRowInsertedAsync(SavedRowItem<Contact, Dictionary<string, object>> contact)
|
||||
{
|
||||
Contact newContact = await ResolveContactAsync(contact.Item);
|
||||
if (newContact.Account == null)
|
||||
return;
|
||||
int count = await genericController.InsertAsync(newContact);
|
||||
Console.WriteLine($"Inserted {count} properties for new contact {newContact.ContactId}: {newContact.FirstName} {newContact.LastName}.");
|
||||
}
|
||||
|
||||
private async Task OnRowInsertedAsync(SavedRowItem<Contact, Dictionary<string, object>> contact) {
|
||||
Contact newContact = await ResolveContactAsync(contact.Item);
|
||||
if (newContact.Account == null)
|
||||
return;
|
||||
int count = await genericController.InsertAsync(newContact);
|
||||
Console.WriteLine($"Inserted {count} properties for new contact {newContact.ContactId}: {newContact.FirstName} {newContact.LastName}.");
|
||||
}
|
||||
private async Task OnRowUpdatedAsync(SavedRowItem<Contact, Dictionary<string, object>> contact)
|
||||
{
|
||||
Contact newContact = await ResolveContactAsync(contact.Item);
|
||||
if (newContact.Account == null)
|
||||
return;
|
||||
int count = await genericController.UpdateAsync(contact.Item);
|
||||
Console.WriteLine($"Updated {count} properties in contact {newContact.ContactId}: {newContact.FirstName} {newContact.LastName}.");
|
||||
}
|
||||
|
||||
private async Task OnRowUpdatedAsync(SavedRowItem<Contact, Dictionary<string, object>> contact) {
|
||||
Contact newContact = await ResolveContactAsync(contact.Item);
|
||||
if (newContact.Account == null)
|
||||
return;
|
||||
int count = await genericController.UpdateAsync(contact.Item);
|
||||
Console.WriteLine($"Updated {count} properties in contact {newContact.ContactId}: {newContact.FirstName} {newContact.LastName}.");
|
||||
}
|
||||
private async Task OnRowRemovedAsync(Contact contact)
|
||||
{
|
||||
int count = await genericController.RemoveAsync(contact);
|
||||
Console.WriteLine($"Removed {count} properties and contact {contact.ContactId}: {contact.FirstName} {contact.LastName}.");
|
||||
}
|
||||
|
||||
private async Task OnRowRemovedAsync(Contact contact) {
|
||||
int count = await genericController.RemoveAsync(contact);
|
||||
Console.WriteLine($"Removed {count} properties and contact {contact.ContactId}: {contact.FirstName} {contact.LastName}.");
|
||||
}
|
||||
private async Task<Contact> ResolveContactAsync(Contact newContact)
|
||||
{
|
||||
newContact.Account = await genericController.GetAsync<Account>(a => a.AccountId.Equals(newContact.AccountId));
|
||||
if (newContact.Account != null)
|
||||
{
|
||||
newContact.NoPhoneCalls = false;
|
||||
newContact.EmailBounced = false;
|
||||
newContact.NoHardcopyMailing = false;
|
||||
newContact.ValidatedContact = true;
|
||||
newContact.DataModificationByUser = "Gremlin Blazor Server GUI";
|
||||
newContact.DataVersionNumber++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"No account with AccountId {newContact.AccountId} found!");
|
||||
}
|
||||
|
||||
private async Task<Contact> ResolveContactAsync(Contact newContact) {
|
||||
newContact.Account = await genericController.GetAsync<Account>(a => a.AccountId.Equals(newContact.AccountId));
|
||||
if (newContact.Account != null) {
|
||||
newContact.NoPhoneCalls = false;
|
||||
newContact.EmailBounced = false;
|
||||
newContact.NoHardcopyMailing = false;
|
||||
newContact.ValidatedContact = true;
|
||||
newContact.DataModificationByUser = "Gremlin Blazor Server GUI";
|
||||
newContact.DataVersionNumber++;
|
||||
}
|
||||
else {
|
||||
Console.WriteLine($"No account with AccountId {newContact.AccountId} found!");
|
||||
return newContact;
|
||||
}
|
||||
|
||||
return newContact;
|
||||
}
|
||||
private async Task OnImportContacts(FileChangedEventArgs fileChangedEventArgs)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (IFileEntry? file in fileChangedEventArgs.Files)
|
||||
{
|
||||
using MemoryStream stream = new();
|
||||
await file.WriteToStreamAsync(stream);
|
||||
_ = stream.Seek(0, SeekOrigin.Begin);
|
||||
using StreamReader reader = new(stream);
|
||||
string fileContent = await reader.ReadToEndAsync();
|
||||
_ = await genericImporter.ImportCsvAsync<Account>(fileContent);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine(exception.Message);
|
||||
}
|
||||
|
||||
private async Task OnImportContacts(FileChangedEventArgs fileChangedEventArgs) {
|
||||
try {
|
||||
foreach (IFileEntry? file in fileChangedEventArgs.Files) {
|
||||
using MemoryStream stream = new();
|
||||
await file.WriteToStreamAsync(stream);
|
||||
_ = stream.Seek(0, SeekOrigin.Begin);
|
||||
using StreamReader reader = new(stream);
|
||||
string fileContent = await reader.ReadToEndAsync();
|
||||
_ = await genericImporter.ImportCsvAsync<Account>(fileContent);
|
||||
}
|
||||
StateHasChanged();
|
||||
return;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Console.WriteLine(exception.Message);
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1,243 +1,262 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Blazorise;
|
||||
using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
using Gremlin_BlazorServer.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.JSInterop;
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace Gremlin_BlazorServer.Pages.Quotes;
|
||||
|
||||
public partial class QuoteAdd {
|
||||
[CascadingParameter] private Task<AuthenticationState>? AuthenticationStateTask { get; set; }
|
||||
[Inject] public IModalService? ModalService { get; set; }
|
||||
|
||||
private IList<Contact>? contacts;
|
||||
private Quote quote = new();
|
||||
private Contact? selectedContact;
|
||||
private readonly CultureInfo cultureInfo = new("de-DE");
|
||||
private bool pdfNotReady = true;
|
||||
private bool isCreatingPdf;
|
||||
private bool texNotReady = true;
|
||||
private bool isCreatingTex;
|
||||
private bool lineItemsNotReady = true;
|
||||
private string? url;
|
||||
private readonly bool debug;
|
||||
private List<CustomDescription>? suggestedCustomDescriptions;
|
||||
private CustomDescription? newCustomDescription;
|
||||
private LineItem? selectedLineItem;
|
||||
|
||||
public Task ShowCustomDescriptionModal() =>
|
||||
ModalService.Show<CustomDescriptionModal>(builder => {
|
||||
builder.Add(parameter => parameter.CustomDescription, newCustomDescription);
|
||||
builder.Add(parameter => parameter.SuggestedCustomDescriptions, suggestedCustomDescriptions);
|
||||
});
|
||||
|
||||
protected override async Task OnParametersSetAsync() {
|
||||
if (AuthenticationStateTask != null) {
|
||||
ClaimsPrincipal user = (await AuthenticationStateTask).User;
|
||||
if (user.Identity is { IsAuthenticated: true }) {
|
||||
await ApplicationLoadingIndicatorService.Show();
|
||||
contacts = await genericController.GetAllAsync<Contact>();
|
||||
await ApplicationLoadingIndicatorService.Hide();
|
||||
quote = await GenerateNewQuote(quote, "Woitschetzki");
|
||||
}
|
||||
public partial class QuoteAdd
|
||||
{
|
||||
[CascadingParameter] private Task<AuthenticationState>? AuthenticationStateTask { get; set; }
|
||||
[Inject] public IModalService? ModalService { get; set; }
|
||||
|
||||
private IList<Contact>? contacts;
|
||||
private Quote? quote;
|
||||
private Contact? selectedContact;
|
||||
private readonly CultureInfo cultureInfo = new("de-DE");
|
||||
private bool pdfNotReady = true;
|
||||
private bool isCreatingPdf;
|
||||
private bool texNotReady = true;
|
||||
private bool isCreatingTex;
|
||||
private bool lineItemsNotReady = true;
|
||||
private string? url;
|
||||
private readonly bool debug;
|
||||
private List<CustomDescription>? suggestedCustomDescriptions;
|
||||
private CustomDescription? newCustomDescription;
|
||||
private LineItem? selectedLineItem;
|
||||
|
||||
public Task ShowCustomDescriptionModal() =>
|
||||
ModalService.Show<CustomDescriptionModal>(builder =>
|
||||
{
|
||||
builder.Add(parameter => parameter.CustomDescription, newCustomDescription);
|
||||
builder.Add(parameter => parameter.SuggestedCustomDescriptions, suggestedCustomDescriptions);
|
||||
});
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (AuthenticationStateTask != null)
|
||||
{
|
||||
ClaimsPrincipal user = (await AuthenticationStateTask).User;
|
||||
if (user.Identity is { IsAuthenticated: true })
|
||||
{
|
||||
await ApplicationLoadingIndicatorService.Show();
|
||||
contacts = await genericController.GetAllAsync<Contact>();
|
||||
await ApplicationLoadingIndicatorService.Hide();
|
||||
quote = await GenerateNewQuote(quote, "Woitschetzki");
|
||||
}
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
private async Task<Quote> GenerateNewQuote(Quote? _quote, string salesRepLastName)
|
||||
{
|
||||
if (_quote == null)
|
||||
{
|
||||
_quote = new();
|
||||
await genericController.InsertAsync(_quote);
|
||||
}
|
||||
|
||||
_quote.SalesRep = await genericController.GetAsync<Contact>(c => c.LastName == salesRepLastName);
|
||||
if (_quote.SalesRep != null)
|
||||
//Read Account seperatly to avoid new creation of account
|
||||
_quote.SalesRep.Account = await genericController.GetAsync<Account>(a => a.AccountId == _quote.SalesRep.AccountId);
|
||||
|
||||
Quote? lastQuote = genericController.GetLast<Quote>();
|
||||
_quote.QuoteId = lastQuote != null ? lastQuote.QuoteId + 1 : 1;
|
||||
|
||||
_quote.QuotationNumber = _quote.SalesRep != null ? _quote.SalesRep.LastName switch
|
||||
{
|
||||
"Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{_quote.QuoteId}",
|
||||
"Welsch" => $"DE-83RE32-{DateTime.Now:My}-{_quote.QuoteId}",
|
||||
_ => $"DE-XXYYXX-{DateTime.Now:My}-{_quote.QuoteId}"
|
||||
}
|
||||
: $"DE-XXYYXX-{DateTime.Now:My}-{_quote.QuoteId}";
|
||||
|
||||
_quote.Description = "Gerät";
|
||||
TryToSaveQuote(_quote);
|
||||
|
||||
return _quote;
|
||||
}
|
||||
|
||||
private async Task TryToSaveQuote(Quote _quote)
|
||||
{
|
||||
if (await genericController.UpdateAsync(_quote) > 0)
|
||||
Debug.WriteLine("Speichern der Quote erfolgreich.");
|
||||
else
|
||||
Debug.WriteLine("Fehler beim Speichern der Quote!");
|
||||
return;
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
private async Task<Quote> GenerateNewQuote(Quote _quote, string salesRepLastName) {
|
||||
if (_quote == null)
|
||||
return new();
|
||||
_quote.SalesRep = await genericController.GetAsync<Contact>(
|
||||
c => c.LastName.Equals(salesRepLastName),
|
||||
"Account"
|
||||
);
|
||||
Quote? lastQuote = genericController.GetLast<Quote>();
|
||||
_quote.QuoteId = lastQuote != null ? lastQuote.QuoteId + 1 : 1;
|
||||
|
||||
_quote.QuotationNumber =
|
||||
_quote.SalesRep != null
|
||||
? _quote.SalesRep.LastName switch {
|
||||
"Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{_quote.QuoteId}",
|
||||
"Welsch" => $"DE-83RE32-{DateTime.Now:My}-{_quote.QuoteId}",
|
||||
_ => $"DE-XXYYXX-{DateTime.Now:My}-{_quote.QuoteId}"
|
||||
private async Task SelectQuoteOnChanged(FileChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (IFileEntry? file in e.Files)
|
||||
{
|
||||
using MemoryStream stream = new();
|
||||
await file.WriteToStreamAsync(stream);
|
||||
_ = stream.Seek(0, SeekOrigin.Begin);
|
||||
using StreamReader reader = new(stream);
|
||||
string fileContent = await reader.ReadToEndAsync();
|
||||
quote = QuoteHandling.ReadLineItems(quote, fileContent);
|
||||
if (quote.Recipient?.Account?.AccountName != null) quote = hostingService.SetPath(quote);
|
||||
if (quote.LineItems == null) return;
|
||||
|
||||
FileService.WriteQuoteToTsv(fileContent, quote);
|
||||
|
||||
//TODO Load all relevant CustomDescriptions upfront
|
||||
for (int i = 0; i < quote.LineItems.Count; i++)
|
||||
{
|
||||
newCustomDescription = await genericController.GetAsync<CustomDescription>(
|
||||
newCustomDescription => newCustomDescription.ProductNumber.Equals(quote.LineItems[i].ProductNumber, StringComparison.Ordinal)
|
||||
&& newCustomDescription.OptionNumber.Equals(quote.LineItems[i].OptionNumber, StringComparison.Ordinal)
|
||||
);
|
||||
|
||||
if (newCustomDescription == null)
|
||||
{
|
||||
Console.WriteLine($"Keine CustomDescription für {quote.LineItems[i].ProductNumber}#{quote.LineItems[i].OptionNumber} verfügbar!");
|
||||
suggestedCustomDescriptions = await SuggestCustomDescriptions(quote.LineItems[i]);
|
||||
newCustomDescription = new()
|
||||
{
|
||||
ProductNumber = quote.LineItems[i].ProductNumber,
|
||||
OptionNumber = quote.LineItems[i].OptionNumber,
|
||||
Heading = quote.LineItems[i].SapShortDescription,
|
||||
DescriptionText = quote.LineItems[i].SapLongDescription
|
||||
};
|
||||
|
||||
//Show windows to edit new cD
|
||||
await ShowCustomDescriptionModal();
|
||||
//TODO need to wait for modal!
|
||||
|
||||
//Insert new CustomDescription to db
|
||||
newCustomDescription.AccountId = 1;
|
||||
_ = await genericController.InsertAsync(newCustomDescription);
|
||||
}
|
||||
|
||||
//read cD form db to cleanup ChangeTracker
|
||||
quote.LineItems[i].CustomDescription = await genericController.GetAsync<CustomDescription>(cD => cD.CustomDescriptionId.Equals(newCustomDescription.CustomDescriptionId));
|
||||
}
|
||||
}
|
||||
: $"DE-XXYYXX-{DateTime.Now:My}-{_quote.QuoteId}";
|
||||
|
||||
_quote.Description = "Gerät";
|
||||
return _quote;
|
||||
}
|
||||
|
||||
private async Task SelectQuoteOnChanged(FileChangedEventArgs e) {
|
||||
try {
|
||||
foreach (IFileEntry? file in e.Files) {
|
||||
using MemoryStream stream = new();
|
||||
await file.WriteToStreamAsync(stream);
|
||||
_ = stream.Seek(0, SeekOrigin.Begin);
|
||||
using StreamReader reader = new(stream);
|
||||
string fileContent = await reader.ReadToEndAsync();
|
||||
quote = QuoteHandling.ReadLineItems(quote, fileContent);
|
||||
if (quote.Recipient?.Account?.AccountName != null) quote = hostingService.SetPath(quote);
|
||||
if (quote.LineItems == null) return;
|
||||
|
||||
FileService.WriteQuoteToTsv(fileContent, quote);
|
||||
|
||||
//TODO Load all relevant CustomDescriptions upfront
|
||||
for (int i = 0; i < quote.LineItems.Count; i++) {
|
||||
newCustomDescription = await genericController.GetAsync<CustomDescription>(
|
||||
newCustomDescription =>
|
||||
newCustomDescription.ProductNumber.Equals(
|
||||
quote.LineItems[i].ProductNumber,
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
&& newCustomDescription.OptionNumber.Equals(
|
||||
quote.LineItems[i].OptionNumber,
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
);
|
||||
|
||||
if (newCustomDescription == null) {
|
||||
Console.WriteLine(
|
||||
$"Keine CustomDescription für {quote.LineItems[i].ProductNumber}#{quote.LineItems[i].OptionNumber} verfügbar!"
|
||||
);
|
||||
suggestedCustomDescriptions = await SuggestCustomDescriptions(
|
||||
quote.LineItems[i]
|
||||
);
|
||||
newCustomDescription = new() {
|
||||
ProductNumber = quote.LineItems[i].ProductNumber,
|
||||
OptionNumber = quote.LineItems[i].OptionNumber,
|
||||
Heading = quote.LineItems[i].SapShortDescription,
|
||||
DescriptionText = quote.LineItems[i].SapLongDescription
|
||||
};
|
||||
|
||||
//Show windows to edit new cD
|
||||
await ShowCustomDescriptionModal();
|
||||
//TODO need to wait for modal!
|
||||
|
||||
//Insert new CustomDescription to db
|
||||
newCustomDescription.AccountId = 1;
|
||||
_ = await genericController.InsertAsync(newCustomDescription);
|
||||
}
|
||||
|
||||
//read cD form db to cleanup ChangeTracker
|
||||
quote.LineItems[i].CustomDescription =
|
||||
await genericController.GetAsync<CustomDescription>(cD => cD.CustomDescriptionId == newCustomDescription.CustomDescriptionId);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine(exc.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (quote.Recipient != null) lineItemsNotReady = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
catch (Exception exc) {
|
||||
Console.WriteLine(exc.Message);
|
||||
|
||||
private async Task<List<CustomDescription>?> SuggestCustomDescriptions(LineItem lineItem)
|
||||
{
|
||||
//IList<CustomDescription>? fromProductNumber = await genericController.GetAllAsync<CustomDescription>(cD => cD.ProductNumber.Equals(lineItem.ProductNumber, StringComparison.Ordinal));
|
||||
IList<CustomDescription>? fromOptionNumber = new List<CustomDescription>();
|
||||
if (lineItem.OptionNumber != "")
|
||||
fromOptionNumber = await genericController.GetAllAsync<CustomDescription>(cD => cD.OptionNumber.Equals(lineItem.OptionNumber, StringComparison.Ordinal));
|
||||
//if (fromOptionNumber == null && fromProductNumber == null) return null;
|
||||
//if (fromOptionNumber == null) return fromProductNumber.ToList();
|
||||
//if (fromProductNumber == null) return fromOptionNumber.ToList();
|
||||
//return fromProductNumber.Union(fromOptionNumber).ToList();
|
||||
return fromOptionNumber.ToList();
|
||||
}
|
||||
finally {
|
||||
if (quote.Recipient != null)
|
||||
lineItemsNotReady = false;
|
||||
StateHasChanged();
|
||||
|
||||
private static void SelectQuoteOnWritten(FileWrittenEventArgs e) =>
|
||||
Console.WriteLine($"File: {e.File.Name} Position: {e.Position} Data: {Convert.ToBase64String(e.Data)}");
|
||||
|
||||
private static void SelectQuoteOnProgressed(FileProgressedEventArgs e) =>
|
||||
Console.WriteLine($"File: {e.File.Name} Progress: {e.Percentage}");
|
||||
|
||||
private async Task OnSelectedContactChanged(Contact _selectedContact)
|
||||
{
|
||||
if (quote == null) return;
|
||||
quote.Recipient = await genericController.GetAsync<Contact>(c => c.ContactId.Equals(_selectedContact.ContactId));
|
||||
|
||||
if (quote.Recipient != null)
|
||||
//Read account seperatly to avoid new generation
|
||||
quote.Recipient.Account = await genericController.GetAsync<Account>(a => a.AccountId.Equals(quote.Recipient.AccountId));
|
||||
|
||||
if (quote.LineItems != null && quote.Recipient != null && quote.Recipient.Account != null) lineItemsNotReady = false;
|
||||
|
||||
selectedContact = _selectedContact;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<CustomDescription>?> SuggestCustomDescriptions(LineItem lineItem) {
|
||||
//IList<CustomDescription>? fromProductNumber = await genericController.GetAllAsync<CustomDescription>(cD => cD.ProductNumber.Equals(lineItem.ProductNumber, StringComparison.Ordinal));
|
||||
IList<CustomDescription>? fromOptionNumber = new List<CustomDescription>();
|
||||
if (lineItem.OptionNumber != "") {
|
||||
fromOptionNumber = await genericController.GetAllAsync<CustomDescription>(
|
||||
cD => cD.OptionNumber.Equals(lineItem.OptionNumber, StringComparison.Ordinal)
|
||||
);
|
||||
|
||||
private async Task OnSave()
|
||||
{
|
||||
//HACK Try to avoid new generation of FKs
|
||||
// quote.Recipient = new() { Account = new() };
|
||||
// quote.SalesRep = new() { Account = new() };
|
||||
// quote.LineItems = null;
|
||||
|
||||
if (await genericController.UpdateAsync(quote) > 0)
|
||||
navigationManager.NavigateTo("Quotes/QuoteIndex");
|
||||
}
|
||||
//if (fromOptionNumber == null && fromProductNumber == null) return null;
|
||||
//if (fromOptionNumber == null) return fromProductNumber.ToList();
|
||||
//if (fromProductNumber == null) return fromOptionNumber.ToList();
|
||||
//return fromProductNumber.Union(fromOptionNumber).ToList();
|
||||
return fromOptionNumber.ToList();
|
||||
}
|
||||
|
||||
private static void SelectQuoteOnWritten(FileWrittenEventArgs e) =>
|
||||
Console.WriteLine(
|
||||
$"File: {e.File.Name} Position: {e.Position} Data: {Convert.ToBase64String(e.Data)}"
|
||||
);
|
||||
|
||||
private static void SelectQuoteOnProgressed(FileProgressedEventArgs e) =>
|
||||
Console.WriteLine($"File: {e.File.Name} Progress: {e.Percentage}");
|
||||
|
||||
private async Task OnSelectedContactChanged(Contact _selectedContact) {
|
||||
selectedContact = _selectedContact;
|
||||
quote.Recipient = await genericController.GetAsync<Contact>(c => c.ContactId == _selectedContact.ContactId);
|
||||
if (quote.Recipient != null)
|
||||
quote.Recipient.Account = await genericController.GetAsync<Account>(a => a.AccountId.Equals(quote.Recipient.AccountId));
|
||||
if (quote.LineItems != null && quote.Recipient != null)
|
||||
lineItemsNotReady = false;
|
||||
}
|
||||
|
||||
private async Task OnSave() {
|
||||
//HACK remove something from quote to make save possible
|
||||
// foreach (LineItem lineItem in quote.LineItems)
|
||||
// {
|
||||
// lineItem.CustomDescription = null;
|
||||
// lineItem.CustomDescriptionId = 0;
|
||||
// }
|
||||
// quote.Recipient = null;
|
||||
// quote.ContactId = 0;
|
||||
|
||||
if (await genericController.InsertAsync(quote) > 0)
|
||||
navigationManager.NavigateTo("Quotes/QuoteIndex");
|
||||
}
|
||||
|
||||
private async Task OnCreateTex() {
|
||||
isCreatingTex = true;
|
||||
StringBuilder? tex = await QuoteHandling.CreateTexAsync(quote);
|
||||
if (tex == null)
|
||||
return;
|
||||
quote.Tex = tex.ToString();
|
||||
if (quote.Tex == null)
|
||||
return;
|
||||
await FileService.WriteTexFile(quote);
|
||||
isCreatingTex = false;
|
||||
Console.WriteLine("Tex file succesfull created.");
|
||||
texNotReady = false;
|
||||
}
|
||||
|
||||
private async Task OnCreatePdf() {
|
||||
isCreatingPdf = true;
|
||||
if (await PdfService.CreatePdf(quote)) {
|
||||
pdfNotReady = false;
|
||||
isCreatingPdf = false;
|
||||
Console.WriteLine("PDF successfull written.");
|
||||
url = HostingService.GetPdfUrl(quote);
|
||||
Console.WriteLine($"URL to PDF is {url}");
|
||||
|
||||
private async Task OnCreateTex()
|
||||
{
|
||||
isCreatingTex = true;
|
||||
StringBuilder? tex = await QuoteHandling.CreateTexAsync(quote);
|
||||
|
||||
if (tex == null) return;
|
||||
quote.Tex = tex.ToString();
|
||||
|
||||
if (quote.Tex == null) return;
|
||||
await FileService.WriteTexFile(quote);
|
||||
|
||||
isCreatingTex = false;
|
||||
Console.WriteLine("Tex file succesfull created.");
|
||||
texNotReady = false;
|
||||
}
|
||||
|
||||
private async Task OnCreatePdf()
|
||||
{
|
||||
isCreatingPdf = true;
|
||||
if (await PdfService.CreatePdf(quote))
|
||||
{
|
||||
pdfNotReady = false;
|
||||
isCreatingPdf = false;
|
||||
Console.WriteLine("PDF successfull written.");
|
||||
url = HostingService.GetPdfUrl(quote);
|
||||
Console.WriteLine($"URL to PDF is {url}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOpenPdfApp() => PdfService.OpenPdfWithOkular(quote);
|
||||
private void OnOpenPdfApp() => PdfService.OpenPdfWithOkular(quote);
|
||||
|
||||
private async Task OnOpenPdfNewTab() =>
|
||||
await jSRuntime.InvokeVoidAsync("OpenNewTab", $"quotes/{url}");
|
||||
private async Task OnOpenPdfNewTab() =>
|
||||
await jSRuntime.InvokeVoidAsync("OpenNewTab", $"quotes/{url}");
|
||||
|
||||
private void OnDescriptionChanged(string description) => quote.Description = description;
|
||||
private void OnDescriptionChanged(string description) => quote.Description = description;
|
||||
|
||||
private void OnQuotationNumberChanged(string quotationNumber) =>
|
||||
quote.QuotationNumber = quotationNumber;
|
||||
private void OnQuotationNumberChanged(string quotationNumber) =>
|
||||
quote.QuotationNumber = quotationNumber;
|
||||
|
||||
private void OnValidForChanged(string validFor) => quote.ValidFor = byte.Parse(validFor);
|
||||
private void OnValidForChanged(string validFor) => quote.ValidFor = byte.Parse(validFor);
|
||||
|
||||
private void OnVATChanged(string vat) => quote.Vat = float.Parse(vat);
|
||||
private void OnVATChanged(string vat) => quote.Vat = float.Parse(vat);
|
||||
|
||||
private void OnIsPriceInformationChanged(bool isPriceInformation) =>
|
||||
quote.IsPriceInformation = isPriceInformation;
|
||||
private void OnIsPriceInformationChanged(bool isPriceInformation) =>
|
||||
quote.IsPriceInformation = isPriceInformation;
|
||||
|
||||
private void OnShowBruttoChanged(bool onShowBrutto) => quote.ShowBrutto = onShowBrutto;
|
||||
private void OnShowBruttoChanged(bool onShowBrutto) => quote.ShowBrutto = onShowBrutto;
|
||||
|
||||
private void OnShowDiscountsChanged(bool showDiscount) => quote.ShowDiscounts = showDiscount;
|
||||
private void OnShowDiscountsChanged(bool showDiscount) => quote.ShowDiscounts = showDiscount;
|
||||
|
||||
private void OnShowSinglePricesChanged(bool showSinglePrices) =>
|
||||
quote.ShowSinglePrices = showSinglePrices;
|
||||
private void OnShowSinglePricesChanged(bool showSinglePrices) =>
|
||||
quote.ShowSinglePrices = showSinglePrices;
|
||||
|
||||
private void OnSelectedLineItemChanged(LineItem _selectedLineItem) =>
|
||||
selectedLineItem = _selectedLineItem;
|
||||
private void OnSelectedLineItemChanged(LineItem _selectedLineItem) =>
|
||||
selectedLineItem = _selectedLineItem;
|
||||
|
||||
private void OnWarrantyChanged(string warranty) => quote.Warranty = int.Parse(warranty);
|
||||
private void OnWarrantyChanged(string warranty) => quote.Warranty = int.Parse(warranty);
|
||||
|
||||
private void OnCancel() => navigationManager.NavigateTo("Quotes/QuoteIndex");
|
||||
private void OnCancel() => navigationManager.NavigateTo("Quotes/QuoteIndex");
|
||||
}
|
||||
|
||||
@ -1,48 +1,57 @@
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
using Gremlin_BlazorServer.Data.EntityClasses;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Gremlin_BlazorServer.Pages.Quotes {
|
||||
public partial class QuoteIndex {
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState>? authenticationStateTask { get; set; }
|
||||
namespace Gremlin_BlazorServer.Pages.Quotes
|
||||
{
|
||||
public partial class QuoteIndex
|
||||
{
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState>? authenticationStateTask { get; set; }
|
||||
|
||||
private IList<Quote>? quotes;
|
||||
private Quote? selectedQuote;
|
||||
private readonly CultureInfo cultureInfo = new("de-DE");
|
||||
private string selectedTab = "details";
|
||||
protected override async Task OnInitializedAsync() {
|
||||
if (authenticationStateTask != null) {
|
||||
ClaimsPrincipal user = (await authenticationStateTask).User;
|
||||
if (user.Identity is { IsAuthenticated: true }) {
|
||||
quotes = await genericController.GetAllAsync<Quote>();
|
||||
}
|
||||
}
|
||||
private IList<Quote>? quotes;
|
||||
private Quote? selectedQuote;
|
||||
private readonly CultureInfo cultureInfo = new("de-DE");
|
||||
private string selectedTab = "details";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (authenticationStateTask != null)
|
||||
{
|
||||
ClaimsPrincipal user = (await authenticationStateTask).User;
|
||||
if (user.Identity is { IsAuthenticated: true })
|
||||
{
|
||||
quotes = await genericController.GetAllAsync<Quote>();
|
||||
}
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
private async Task OnSelectedQuoteChanged(Quote _selectedQuote) {
|
||||
selectedQuote = _selectedQuote;
|
||||
selectedQuote.Recipient = await genericController.GetAsync<Contact>(c => c.ContactId.Equals(selectedQuote.ContactId));
|
||||
if (selectedQuote.Recipient != null && selectedQuote != null) {
|
||||
selectedQuote = await genericController.GetAsync<Quote>(c => c.QuoteId.Equals(_selectedQuote.QuoteId), "Recipient", "LineItems");
|
||||
selectedQuote.Recipient.Account = await genericController.GetAsync<Account>(a => a.AccountId.Equals(selectedQuote.Recipient.AccountId));
|
||||
}
|
||||
private async Task OnSelectedQuoteChanged(Quote _selectedQuote)
|
||||
{
|
||||
selectedQuote = _selectedQuote;
|
||||
selectedQuote.Recipient = await genericController.GetAsync<Contact>(c => c.ContactId.Equals(selectedQuote.RecipientId));
|
||||
if (selectedQuote.Recipient != null && selectedQuote != null)
|
||||
{
|
||||
selectedQuote = await genericController.GetAsync<Quote>(c => c.QuoteId.Equals(_selectedQuote.QuoteId), "Recipient", "LineItems");
|
||||
selectedQuote.Recipient.Account = await genericController.GetAsync<Account>(a => a.AccountId.Equals(selectedQuote.Recipient.AccountId));
|
||||
}
|
||||
|
||||
//selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.Quote.Equals(selectedQuote));
|
||||
return;
|
||||
}
|
||||
//selectedQuote.LineItems = await genericController.GetAllAsync<LineItem>(lI => lI.Quote.Equals(selectedQuote));
|
||||
return;
|
||||
}
|
||||
|
||||
private void OnCreateNewQuote() {
|
||||
navigationManager.NavigateTo("Quotes/QuoteAdd");
|
||||
}
|
||||
private void OnCreateNewQuote()
|
||||
{
|
||||
navigationManager.NavigateTo("Quotes/QuoteAdd");
|
||||
}
|
||||
|
||||
private Task OnSelectedTabChanged(string _selectedTab) {
|
||||
selectedTab = _selectedTab;
|
||||
return Task.CompletedTask;
|
||||
private Task OnSelectedTabChanged(string _selectedTab)
|
||||
{
|
||||
selectedTab = _selectedTab;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
# 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 G7110B 29 1260 Infinity II isokratische Pumpe 1 8908 0 0 45 4899.4 4899.4 45 0 0 0 ISL100P1 Pumps
|
||||
2 G7110B 001 29 HPLC System Tool Kit 1260 Infinity II 1 400 0 0 45 220 220 45 0 0 0
|
||||
3 G7110B 094 29 Poroshell 120 EC-C18 3,0x150mm, 2,7um 1 1 0 0 45 0.55 0.55 45 0 0 0
|
||||
4 G7116A 29 1260 Infinity II Therm. f. mehr. Saeulen 1 6494 0 0 45 3571.7 3571.7 45 0 0 0 ISL100LC1 LC Hardware
|
||||
5 G7129A 29 1260 Inf. II Fluessigprobengeber 1 19905 0 0 45 10947.75 10947.75 45 0 0 0 ISL100A1 Autosamplers
|
||||
6 G7129A 010 29 Standard-Schublade (6x11 Probenflaschen) 1 375 0 0 45 206.25 206.25 45 0 0 0
|
||||
7 G7162A 29 1260 Infinity II Brechungsindexdetektor 1 13989 0 0 45 7693.95 7693.95 45 0 0 0 ISL100D1 Detectors
|
||||
8 G7114A 29 1260 Infinity II VW-Detektor 1 9307 0 0 45 5118.85 5118.85 45 0 0 0 ISL100D1 Detectors
|
||||
9 G7114A 018 29 Standarddurchflusszelle VWD 1 1612 0 0 45 886.6 886.6 45 0 0 0
|
||||
10 G7850AA 29 Agilent GPC/SEC-Software 1 14789 0 0 45 8133.95 8133.95 45 0 0 0 ISL230L230 Special LC
|
||||
11 PL1110-6125 BC PLgel 10um 500A 300 x 7.5 mm 2 1806 0 0 45 993.3 1986.6 45 0 0 0 CSCV27C04L GPC/SEC - PLgel
|
||||
12 PL1110-6120 BC PLgel 10um 100A 300 x 7.5 mm 2 1806 0 0 45 993.3 1986.6 45 0 0 0 CSCV27C04L GPC/SEC - PLgel
|
||||
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 2C9 74 Einweisung zum ersten Methodenlauf 1 1034 0 0 20 827.2 827.2 20 0 0 0 TSSTRN Training Services
|
||||
15 SYS-LC-1260II 8R1 74 CrossLab Silver - 1J, kompl. 1 2688 0 0 20 2150.4 2150.4 20 0 0 0 TSSYS1 Serviced As Systems - 1 YR
|
||||
|
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
# 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 G7110B 29 1260 Infinity II isokratische Pumpe 1 8908 0 0 45 4899.4 4899.4 45 0 0 0 ISL100P1 Pumps
|
||||
2 G7110B 001 29 HPLC System Tool Kit 1260 Infinity II 1 400 0 0 45 220 220 45 0 0 0
|
||||
3 G7110B 094 29 Poroshell 120 EC-C18 3,0x150mm, 2,7um 1 1 0 0 45 0.55 0.55 45 0 0 0
|
||||
4 G7116A 29 1260 Infinity II Therm. f. mehr. Saeulen 1 6494 0 0 45 3571.7 3571.7 45 0 0 0 ISL100LC1 LC Hardware
|
||||
5 G7129A 29 1260 Inf. II Fluessigprobengeber 1 19905 0 0 45 10947.75 10947.75 45 0 0 0 ISL100A1 Autosamplers
|
||||
6 G7129A 010 29 Standard-Schublade (6x11 Probenflaschen) 1 375 0 0 45 206.25 206.25 45 0 0 0
|
||||
7 G7162A 29 1260 Infinity II Brechungsindexdetektor 1 13989 0 0 45 7693.95 7693.95 45 0 0 0 ISL100D1 Detectors
|
||||
8 G7114A 29 1260 Infinity II VW-Detektor 1 9307 0 0 45 5118.85 5118.85 45 0 0 0 ISL100D1 Detectors
|
||||
9 G7114A 018 29 Standarddurchflusszelle VWD 1 1612 0 0 45 886.6 886.6 45 0 0 0
|
||||
10 G7850AA 29 Agilent GPC/SEC-Software 1 14789 0 0 45 8133.95 8133.95 45 0 0 0 ISL230L230 Special LC
|
||||
11 PL1110-6125 BC PLgel 10um 500A 300 x 7.5 mm 2 1806 0 0 45 993.3 1986.6 45 0 0 0 CSCV27C04L GPC/SEC - PLgel
|
||||
12 PL1110-6120 BC PLgel 10um 100A 300 x 7.5 mm 2 1806 0 0 45 993.3 1986.6 45 0 0 0 CSCV27C04L GPC/SEC - PLgel
|
||||
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 2C9 74 Einweisung zum ersten Methodenlauf 1 1034 0 0 20 827.2 827.2 20 0 0 0 TSSTRN Training Services
|
||||
15 SYS-LC-1260II 8R1 74 CrossLab Silver - 1J, kompl. 1 2688 0 0 20 2150.4 2150.4 20 0 0 0 TSSYS1 Serviced As Systems - 1 YR
|
||||
|
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
# 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 G7110B 29 1260 Infinity II isokratische Pumpe 1 8908 0 0 45 4899.4 4899.4 45 0 0 0 ISL100P1 Pumps
|
||||
2 G7110B 001 29 HPLC System Tool Kit 1260 Infinity II 1 400 0 0 45 220 220 45 0 0 0
|
||||
3 G7110B 094 29 Poroshell 120 EC-C18 3,0x150mm, 2,7um 1 1 0 0 45 0.55 0.55 45 0 0 0
|
||||
4 G7116A 29 1260 Infinity II Therm. f. mehr. Saeulen 1 6494 0 0 45 3571.7 3571.7 45 0 0 0 ISL100LC1 LC Hardware
|
||||
5 G7129A 29 1260 Inf. II Fluessigprobengeber 1 19905 0 0 45 10947.75 10947.75 45 0 0 0 ISL100A1 Autosamplers
|
||||
6 G7129A 010 29 Standard-Schublade (6x11 Probenflaschen) 1 375 0 0 45 206.25 206.25 45 0 0 0
|
||||
7 G7162A 29 1260 Infinity II Brechungsindexdetektor 1 13989 0 0 45 7693.95 7693.95 45 0 0 0 ISL100D1 Detectors
|
||||
8 G7114A 29 1260 Infinity II VW-Detektor 1 9307 0 0 45 5118.85 5118.85 45 0 0 0 ISL100D1 Detectors
|
||||
9 G7114A 018 29 Standarddurchflusszelle VWD 1 1612 0 0 45 886.6 886.6 45 0 0 0
|
||||
10 G7850AA 29 Agilent GPC/SEC-Software 1 14789 0 0 45 8133.95 8133.95 45 0 0 0 ISL230L230 Special LC
|
||||
11 PL1110-6125 BC PLgel 10um 500A 300 x 7.5 mm 2 1806 0 0 45 993.3 1986.6 45 0 0 0 CSCV27C04L GPC/SEC - PLgel
|
||||
12 PL1110-6120 BC PLgel 10um 100A 300 x 7.5 mm 2 1806 0 0 45 993.3 1986.6 45 0 0 0 CSCV27C04L GPC/SEC - PLgel
|
||||
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 2C9 74 Einweisung zum ersten Methodenlauf 1 1034 0 0 20 827.2 827.2 20 0 0 0 TSSTRN Training Services
|
||||
15 SYS-LC-1260II 8R1 74 CrossLab Silver - 1J, kompl. 1 2688 0 0 20 2150.4 2150.4 20 0 0 0 TSSYS1 Serviced As Systems - 1 YR
|
||||
|
Loading…
Reference in New Issue