diff --git a/Gremlin_BlazorServer/App.razor b/Gremlin_BlazorServer/App.razor
index 52eacdc..c5f8250 100644
--- a/Gremlin_BlazorServer/App.razor
+++ b/Gremlin_BlazorServer/App.razor
@@ -13,20 +13,6 @@
-
+
-@code {
- private Theme theme = new Theme {
- ColorOptions = new ThemeColorOptions {
- //Primary = "#343A40", //"#2196f3" Grey
- //Secondary = "#A65529",
- Dark = "#001529", //Background
- Link = "#343A40", //Black
- Success = "#e0dfe1", //White
- Danger = "#f44336",
- // other
- },
- //IsGradient = true,
- };
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/App.razor.cs b/Gremlin_BlazorServer/App.razor.cs
new file mode 100644
index 0000000..adbea47
--- /dev/null
+++ b/Gremlin_BlazorServer/App.razor.cs
@@ -0,0 +1,18 @@
+using Blazorise;
+
+namespace Gremlin_BlazorServer;
+
+public partial class App {
+ private readonly Theme theme = new() {
+ ColorOptions = new ThemeColorOptions {
+ //Primary = "#343A40", //"#2196f3" Grey
+ //Secondary = "#A65529",
+ Dark = "#001529", //Background
+ Link = "#343A40", //Black
+ Success = "#e0dfe1", //White
+ Danger = "#f44336",
+ // other
+ },
+ //IsGradient = true,
+ };
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/AccountTypes.razor b/Gremlin_BlazorServer/Pages/AccountTypes.razor
index 51c2322..8ada479 100644
--- a/Gremlin_BlazorServer/Pages/AccountTypes.razor
+++ b/Gremlin_BlazorServer/Pages/AccountTypes.razor
@@ -81,33 +81,3 @@
-@code {
- [CascadingParameter] private Task? authenticationStateTask { get; set; }
-
- IList? accountTypes;
- AccountType? selectedAccountType;
-
- protected override async Task OnInitializedAsync()
- {
- if (authenticationStateTask != null)
- {
- ClaimsPrincipal user = (await authenticationStateTask).User;
-
- if (user.Identity is { IsAuthenticated: true })
- {
-
- accountTypes = await genericController.GetAllAsync("Accounts");
- }
-
- await base.OnInitializedAsync();
- }
- }
-
- private async Task OnSelectedAccountTypeChanged(AccountType _selectedAccountType) {
- if (_selectedAccountType != null)
- {
- selectedAccountType = await genericController.GetAsync(aC => aC.AccountTypeCode == _selectedAccountType.AccountTypeCode, "Accounts");
- }
- }
-
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/AccountTypes.razor.cs b/Gremlin_BlazorServer/Pages/AccountTypes.razor.cs
new file mode 100644
index 0000000..ac67564
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/AccountTypes.razor.cs
@@ -0,0 +1,30 @@
+using Gremlin_BlazorServer.Data.EntityClasses;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using System.Security.Claims;
+
+namespace Gremlin_BlazorServer.Pages;
+
+public partial class AccountTypes {
+ [CascadingParameter]
+ private Task? authenticationStateTask { get; set; }
+
+ private IList? accountTypes;
+ private AccountType? selectedAccountType;
+ protected override async Task OnInitializedAsync() {
+ if (authenticationStateTask != null) {
+ ClaimsPrincipal user = (await authenticationStateTask).User;
+ if (user.Identity is { IsAuthenticated: true }) {
+ accountTypes = await genericController.GetAllAsync("Accounts");
+ }
+
+ await base.OnInitializedAsync();
+ }
+ }
+
+ private async Task OnSelectedAccountTypeChanged(AccountType _selectedAccountType) {
+ if (_selectedAccountType != null) {
+ selectedAccountType = await genericController.GetAsync(aC => aC.AccountTypeCode == _selectedAccountType.AccountTypeCode, "Accounts");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Accounts.razor b/Gremlin_BlazorServer/Pages/Accounts.razor
index dc4b67a..a966259 100644
--- a/Gremlin_BlazorServer/Pages/Accounts.razor
+++ b/Gremlin_BlazorServer/Pages/Accounts.razor
@@ -148,78 +148,3 @@
-@code {
-
- [CascadingParameter]
- private Task? authenticationStateTask { get; set; }
-
- private IList? accounts;
- private Account? selectedAccount;
-
- protected override async Task OnInitializedAsync() {
- if (authenticationStateTask != null) {
- ClaimsPrincipal user = (await authenticationStateTask).User;
-
- if (user.Identity is {IsAuthenticated: true }) {
- accounts = await genericController.GetAllAsync("AccountType","SubMarket");
- }
-
- await base.OnInitializedAsync();
- }
- }
-
- private void OnSelectedAccountChanged(Account _selectedAccount) {
- selectedAccount = _selectedAccount;
- selectedAccount.Contacts = genericController.GetAll(c => c.AccountId == selectedAccount.AccountId);
- }
-
- private async Task OnImportAccounts(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(fileContent);
- }
- }
- catch (Exception exception)
- {
- Console.WriteLine(exception.Message);
- }
- StateHasChanged();
- return;
- }
-
-
- private async Task OnRowInsertedAsync(SavedRowItem> account) {
- Account newAccount = await ResolveAccountAsync(account.Item);
- if (newAccount.AccountType == null || newAccount.SubMarket == null) return;
- int count = await genericController.InsertAsync(newAccount);
- Console.WriteLine($"Inserted {count} properties for new account {newAccount.AccountId}: {newAccount.AccountName}.");
-
- }
-
- private async Task OnRowUpdatedAsync(SavedRowItem> account) {
- Account newAccount = await ResolveAccountAsync(account.Item);
- if (newAccount.AccountType == null || newAccount.SubMarket == null) return;
- int count = await genericController.UpdateAsync(account.Item);
- Console.WriteLine($"Updated {count} properties in account {newAccount.AccountId}: {newAccount.AccountName}.");
- }
-
- private async Task OnRowRemovedAsync(Account account) {
- int count = await genericController.RemoveAsync(account);
- Console.WriteLine($"Removed {count} properties and account {account.AccountId}: {account.AccountName}.");
- }
-
- private async Task ResolveAccountAsync(Account newAccount) {
- newAccount.DataModificationByUser = "Gremlin Blazor Server GUI";
- newAccount.DataVersionNumber++;
- newAccount.AccountType = await genericController.GetAsync(aT => aT.AccountTypeCode.Equals("SUP"));
- newAccount.SubMarket = await genericController.GetAsync(sM => sM.SubMarketCode.Equals("VEN"));
- return newAccount;
- }
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Accounts.razor.cs b/Gremlin_BlazorServer/Pages/Accounts.razor.cs
new file mode 100644
index 0000000..119382c
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/Accounts.razor.cs
@@ -0,0 +1,79 @@
+using Blazorise;
+using Blazorise.DataGrid;
+using Gremlin_BlazorServer.Data.EntityClasses;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using System.Security.Claims;
+
+namespace Gremlin_BlazorServer.Pages;
+
+public partial class Accounts {
+ [CascadingParameter]
+ private Task? authenticationStateTask { get; set; }
+
+ private IList? accounts;
+ private Account? selectedAccount;
+ protected override async Task OnInitializedAsync() {
+ if (authenticationStateTask != null) {
+ ClaimsPrincipal user = (await authenticationStateTask).User;
+ if (user.Identity is { IsAuthenticated: true }) {
+ accounts = await genericController.GetAllAsync("AccountType", "SubMarket");
+ }
+
+ await base.OnInitializedAsync();
+ }
+ }
+
+ private void OnSelectedAccountChanged(Account _selectedAccount) {
+ selectedAccount = _selectedAccount;
+ selectedAccount.Contacts = genericController.GetAll(c => c.AccountId == selectedAccount.AccountId);
+ }
+
+ private async Task OnImportAccounts(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(fileContent);
+ }
+ }
+ catch (Exception exception) {
+ Console.WriteLine(exception.Message);
+ }
+
+ StateHasChanged();
+ return;
+ }
+
+ private async Task OnRowInsertedAsync(SavedRowItem> account) {
+ Account newAccount = await ResolveAccountAsync(account.Item);
+ if (newAccount.AccountType == null || newAccount.SubMarket == null)
+ return;
+ int count = await genericController.InsertAsync(newAccount);
+ Console.WriteLine($"Inserted {count} properties for new account {newAccount.AccountId}: {newAccount.AccountName}.");
+ }
+
+ private async Task OnRowUpdatedAsync(SavedRowItem> account) {
+ Account newAccount = await ResolveAccountAsync(account.Item);
+ if (newAccount.AccountType == null || newAccount.SubMarket == null)
+ return;
+ int count = await genericController.UpdateAsync(account.Item);
+ Console.WriteLine($"Updated {count} properties in account {newAccount.AccountId}: {newAccount.AccountName}.");
+ }
+
+ private async Task OnRowRemovedAsync(Account account) {
+ int count = await genericController.RemoveAsync(account);
+ Console.WriteLine($"Removed {count} properties and account {account.AccountId}: {account.AccountName}.");
+ }
+
+ private async Task ResolveAccountAsync(Account newAccount) {
+ newAccount.DataModificationByUser = "Gremlin Blazor Server GUI";
+ newAccount.DataVersionNumber++;
+ newAccount.AccountType = await genericController.GetAsync(aT => aT.AccountTypeCode.Equals("SUP"));
+ newAccount.SubMarket = await genericController.GetAsync(sM => sM.SubMarketCode.Equals("VEN"));
+ return newAccount;
+ }
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Contacts.razor b/Gremlin_BlazorServer/Pages/Contacts.razor
index ca6ed4e..e686e5b 100644
--- a/Gremlin_BlazorServer/Pages/Contacts.razor
+++ b/Gremlin_BlazorServer/Pages/Contacts.razor
@@ -165,98 +165,3 @@
-@code {
-
- [CascadingParameter]
- private Task? authenticationStateTask { get; set; }
-
- private IList? contacts;
- private Contact? selectedContact;
- private List? selectedContacts;
- private Quote? selectedQuote;
- private readonly CultureInfo cultureInfo = new("de-DE");
- private 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();
- }
- }
- await base.OnInitializedAsync();
- }
-
- private async Task OnSelectedContactChanged(Contact _selectedContact) {
- if (_selectedContact != null)
- {
- selectedContact = _selectedContact;
- selectedContact.Quotes = await genericController.GetAllAsync(q => q.ContactId.Equals(selectedContact.ContactId));
- }
- return;
- }
-
- private async Task OnSelectedQuoteChanged(Quote _selectedQuote) {
- if (_selectedQuote != null)
- {
- selectedQuote = _selectedQuote;
- selectedQuote.LineItems = await genericController.GetAllAsync(lI => lI.QuoteId.Equals(selectedQuote.QuoteId));
- }
- return;
- }
-
- private async Task OnRowInsertedAsync(SavedRowItem> 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) {
- 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 ResolveContactAsync(Contact newContact) {
- newContact.Account = await genericController.GetAsync(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;
- }
-
- 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(fileContent);
- }
- }
- catch (Exception exception) {
- Console.WriteLine(exception.Message);
- }
- StateHasChanged();
- return;
- }
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Contacts.razor.cs b/Gremlin_BlazorServer/Pages/Contacts.razor.cs
new file mode 100644
index 0000000..256df66
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/Contacts.razor.cs
@@ -0,0 +1,106 @@
+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? authenticationStateTask { get; set; }
+
+ private IList? contacts;
+ private Contact? selectedContact;
+ private readonly List? 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();
+ }
+ }
+
+ await base.OnInitializedAsync();
+ }
+
+ private async Task OnSelectedContactChanged(Contact _selectedContact) {
+ if (_selectedContact != null) {
+ selectedContact = _selectedContact;
+ selectedContact.Quotes = await genericController.GetAllAsync(q => q.ContactId.Equals(selectedContact.ContactId));
+ }
+
+ return;
+ }
+
+ private async Task OnSelectedQuoteChanged(Quote _selectedQuote) {
+ if (_selectedQuote != null) {
+ selectedQuote = _selectedQuote;
+ selectedQuote.LineItems = await genericController.GetAllAsync(lI => lI.QuoteId.Equals(selectedQuote.QuoteId));
+ }
+
+ return;
+ }
+
+ private async Task OnRowInsertedAsync(SavedRowItem> 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) {
+ 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 ResolveContactAsync(Contact newContact) {
+ newContact.Account = await genericController.GetAsync(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;
+ }
+
+ 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(fileContent);
+ }
+ }
+ catch (Exception exception) {
+ Console.WriteLine(exception.Message);
+ }
+
+ StateHasChanged();
+ return;
+ }
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/CustomDescriptionModal.razor b/Gremlin_BlazorServer/Pages/CustomDescriptionModal.razor
index 63750ac..0a9ff36 100644
--- a/Gremlin_BlazorServer/Pages/CustomDescriptionModal.razor
+++ b/Gremlin_BlazorServer/Pages/CustomDescriptionModal.razor
@@ -4,6 +4,26 @@
+
+ @if (suggestedCustomDescriptions.Count > 0)
+ {
+
+
+
+
+
+
+
+
+ }
+ else {
+ No suggestions available.
+ }
+
ProductNumber
@customDescription.ProductNumber
@@ -27,13 +47,4 @@
-
-
-@code {
- [Inject] public IModalService modalService { get; set; }
- [Parameter] public CustomDescription customDescription { get; set; }
-
- private async Task OnSave() {
- await modalService.Hide();
- }
-}
\ No newline at end of file
+
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/CustomDescriptionModal.razor.cs b/Gremlin_BlazorServer/Pages/CustomDescriptionModal.razor.cs
new file mode 100644
index 0000000..55ba5d5
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/CustomDescriptionModal.razor.cs
@@ -0,0 +1,25 @@
+using Blazorise;
+using Gremlin_BlazorServer.Data.EntityClasses;
+using Microsoft.AspNetCore.Components;
+
+namespace Gremlin_BlazorServer.Pages {
+ public partial class CustomDescriptionModal {
+ [Inject] public IModalService modalService { get; set; }
+
+ [Parameter] public CustomDescription customDescription { get; set; }
+
+ [Parameter] public List suggestedCustomDescriptions { get; set; }
+
+ private CustomDescription? selectedSuggestedCustomDescription;
+ private async Task OnSave() {
+ await modalService.Hide();
+ }
+
+ private void OnSelectedSuggestedCustomDescription(CustomDescription _selectedSuggestedCustomDescriptions) {
+ selectedSuggestedCustomDescription = _selectedSuggestedCustomDescriptions;
+ customDescription.Heading = selectedSuggestedCustomDescription.Heading;
+ customDescription.CoverletterText = selectedSuggestedCustomDescription.CoverletterText;
+ customDescription.DescriptionText = selectedSuggestedCustomDescription.DescriptionText;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/CustomDescriptions.razor b/Gremlin_BlazorServer/Pages/CustomDescriptions.razor
index 6164507..f35f16d 100644
--- a/Gremlin_BlazorServer/Pages/CustomDescriptions.razor
+++ b/Gremlin_BlazorServer/Pages/CustomDescriptions.razor
@@ -95,73 +95,3 @@
-@code {
-
- [CascadingParameter]
- private Task? AuthenticationStateTask { get; set; }
-
- private IList? customDescriptions;
- private CustomDescription? selectedCustomDescription;
-
- protected override async Task OnInitializedAsync() {
- if (AuthenticationStateTask != null) {
- ClaimsPrincipal user = (await AuthenticationStateTask).User;
-
- if (user.Identity is {IsAuthenticated: true }) {
- customDescriptions = genericController.GetAll("Supplier");
- }
-
- await base.OnInitializedAsync();
- }
- }
-
- private void OnSelectedCustomDescriptionChanged(CustomDescription _selectedCustomDescription) {
- selectedCustomDescription = _selectedCustomDescription;
- }
-
- private async Task OnImportCustomDescriptions(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(fileContent);
- }
- }
- catch (Exception exception) {
- Console.WriteLine(exception.Message);
- }
- StateHasChanged();
- return;
- }
-
- private async Task OnRowInsertedAsync(SavedRowItem> customDescription) {
- CustomDescription newCustomDescription = await ResolveCustomDescriptionAsync(customDescription.Item);
- if (newCustomDescription.ProductNumber == null || newCustomDescription.OptionNumber == null) return;
- int count = await genericController.InsertAsync(newCustomDescription);
- Console.WriteLine($"Inserted {count} properties for new custom description {newCustomDescription.ProductNumber}#{newCustomDescription.OptionNumber}: {newCustomDescription.Heading}");
-
- }
-
- private async Task OnRowUpdatedAsync(SavedRowItem> customDescription) {
- CustomDescription newCustomDescription = await ResolveCustomDescriptionAsync(customDescription.Item);
- if (newCustomDescription.ProductNumber == null || newCustomDescription.OptionNumber == null) return;
- int count = await genericController.UpdateAsync(customDescription.Item);
- Console.WriteLine($"Updated {count} properties for custom description {newCustomDescription.ProductNumber}#{newCustomDescription.OptionNumber}: {newCustomDescription.Heading}");
- }
-
- private async Task OnRowRemovedAsync(CustomDescription customDescription) {
- int count = await genericController.RemoveAsync(customDescription);
- Console.WriteLine($"Removed {count} properties and custom description {customDescription.ProductNumber}#{customDescription.OptionNumber}: {customDescription.Heading}");
- }
-
- private async Task ResolveCustomDescriptionAsync(CustomDescription newCustomDescription) {
- newCustomDescription.Supplier = await genericController.GetAsync(a => a.AccountId.Equals(newCustomDescription.AccountId));
- newCustomDescription.DataModificationByUser = "Gremlin Blazor Server GUI";
- newCustomDescription.DataVersionNumber++;
- return newCustomDescription;
- }
-
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/CustomDescriptions.razor.cs b/Gremlin_BlazorServer/Pages/CustomDescriptions.razor.cs
new file mode 100644
index 0000000..05082c5
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/CustomDescriptions.razor.cs
@@ -0,0 +1,75 @@
+using Blazorise;
+using Blazorise.DataGrid;
+using Gremlin_BlazorServer.Data.EntityClasses;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using System.Security.Claims;
+
+namespace Gremlin_BlazorServer.Pages;
+
+public partial class CustomDescriptions {
+ [CascadingParameter]
+ private Task? AuthenticationStateTask { get; set; }
+
+ private IList? customDescriptions;
+ private CustomDescription? selectedCustomDescription;
+ protected override async Task OnInitializedAsync() {
+ if (AuthenticationStateTask != null) {
+ ClaimsPrincipal user = (await AuthenticationStateTask).User;
+ if (user.Identity is { IsAuthenticated: true }) {
+ customDescriptions = genericController.GetAll("Supplier");
+ }
+
+ await base.OnInitializedAsync();
+ }
+ }
+
+ private void OnSelectedCustomDescriptionChanged(CustomDescription _selectedCustomDescription) => selectedCustomDescription = _selectedCustomDescription;
+
+ private async Task OnImportCustomDescriptions(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(fileContent);
+ }
+ }
+ catch (Exception exception) {
+ Console.WriteLine(exception.Message);
+ }
+
+ StateHasChanged();
+ return;
+ }
+
+ private async Task OnRowInsertedAsync(SavedRowItem> customDescription) {
+ CustomDescription newCustomDescription = await ResolveCustomDescriptionAsync(customDescription.Item);
+ if (newCustomDescription.ProductNumber == null || newCustomDescription.OptionNumber == null)
+ return;
+ int count = await genericController.InsertAsync(newCustomDescription);
+ Console.WriteLine($"Inserted {count} properties for new custom description {newCustomDescription.ProductNumber}#{newCustomDescription.OptionNumber}: {newCustomDescription.Heading}");
+ }
+
+ private async Task OnRowUpdatedAsync(SavedRowItem> customDescription) {
+ CustomDescription newCustomDescription = await ResolveCustomDescriptionAsync(customDescription.Item);
+ if (newCustomDescription.ProductNumber == null || newCustomDescription.OptionNumber == null)
+ return;
+ int count = await genericController.UpdateAsync(customDescription.Item);
+ Console.WriteLine($"Updated {count} properties for custom description {newCustomDescription.ProductNumber}#{newCustomDescription.OptionNumber}: {newCustomDescription.Heading}");
+ }
+
+ private async Task OnRowRemovedAsync(CustomDescription customDescription) {
+ int count = await genericController.RemoveAsync(customDescription);
+ Console.WriteLine($"Removed {count} properties and custom description {customDescription.ProductNumber}#{customDescription.OptionNumber}: {customDescription.Heading}");
+ }
+
+ private async Task ResolveCustomDescriptionAsync(CustomDescription newCustomDescription) {
+ newCustomDescription.Supplier = await genericController.GetAsync(a => a.AccountId.Equals(newCustomDescription.AccountId));
+ newCustomDescription.DataModificationByUser = "Gremlin Blazor Server GUI";
+ newCustomDescription.DataVersionNumber++;
+ return newCustomDescription;
+ }
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/LineItems.razor b/Gremlin_BlazorServer/Pages/LineItems.razor
index 760259f..6cbaa88 100644
--- a/Gremlin_BlazorServer/Pages/LineItems.razor
+++ b/Gremlin_BlazorServer/Pages/LineItems.razor
@@ -48,27 +48,3 @@
-@code {
-
- [CascadingParameter]
- private Task? AuthenticationStateTask { get; set; }
-
- private IList? lineItems;
- private LineItem? selectedLineItem;
- private readonly CultureInfo cultureInfo = new("de-DE");
-
- protected override async Task OnInitializedAsync() {
- if (AuthenticationStateTask != null) {
- ClaimsPrincipal user = (await AuthenticationStateTask).User;
-
- if (user.Identity is {IsAuthenticated: true }) {
- lineItems = GenericController.GetAll();
- }
- }
- }
-
- private void OnSelectedLineItemChanged(LineItem _selectedLineItem) {
- selectedLineItem = _selectedLineItem;
- }
-
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/LineItems.razor.cs b/Gremlin_BlazorServer/Pages/LineItems.razor.cs
new file mode 100644
index 0000000..720fd03
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/LineItems.razor.cs
@@ -0,0 +1,27 @@
+using Gremlin_BlazorServer.Data.EntityClasses;
+using Gremlin_BlazorServer.Services;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using System.Globalization;
+using System.Security.Claims;
+
+namespace Gremlin_BlazorServer.Pages;
+
+public partial class LineItems {
+ [CascadingParameter]
+ private Task? AuthenticationStateTask { get; set; }
+
+ private IList? lineItems;
+ private LineItem? selectedLineItem;
+ private readonly CultureInfo cultureInfo = new("de-DE");
+ protected override async Task OnInitializedAsync() {
+ if (AuthenticationStateTask != null) {
+ ClaimsPrincipal user = (await AuthenticationStateTask).User;
+ if (user.Identity is { IsAuthenticated: true }) {
+ lineItems = GenericController.GetAll();
+ }
+ }
+ }
+
+ private void OnSelectedLineItemChanged(LineItem _selectedLineItem) => selectedLineItem = _selectedLineItem;
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/ProductLines.razor b/Gremlin_BlazorServer/Pages/ProductLines.razor
index 642e922..f05cdf6 100644
--- a/Gremlin_BlazorServer/Pages/ProductLines.razor
+++ b/Gremlin_BlazorServer/Pages/ProductLines.razor
@@ -84,60 +84,3 @@
-@code {
- [CascadingParameter] private Task? authenticationStateTask { get; set; }
-
- private IList? productLines;
- private ProductLine? selectedProductLine;
-
- protected override async Task OnParametersSetAsync()
- {
- if (authenticationStateTask != null)
- {
- ClaimsPrincipal user = (await authenticationStateTask).User;
-
- if (user.Identity is { IsAuthenticated: true })
- {
-
- productLines = await genericController.GetAllAsync();
- }
-
- await base.OnInitializedAsync();
- }
- }
-
- private async Task OnSelectedProductLineChanged(ProductLine _selectedProductLine) {
- if (_selectedProductLine != null)
- {
- await ApplicationLoadingIndicatorService.Show();
- selectedProductLine = await genericController.GetAsync(pL => pL.ProductLineCode == _selectedProductLine.ProductLineCode, "Products");
- await ApplicationLoadingIndicatorService.Hide();
- }
- }
-
- private async Task OnRowInsertedAsync(SavedRowItem> productLine) {
- ProductLine newProductLine = await ResolveProductAsync(productLine.Item);
- if (newProductLine.ProductLineCode == null) return;
- int count = await genericController.InsertAsync(newProductLine);
- Console.WriteLine($"Inserted {count} properties for new ProductLine {newProductLine.ProductLineCode}.");
- }
-
- private async Task OnRowUpdatedAsync(SavedRowItem> productLine) {
- ProductLine newProductLine = await ResolveProductAsync(productLine.Item);
- if (newProductLine.ProductLineCode == null) return;
- int count = await genericController.UpdateAsync(productLine.Item);
- Console.WriteLine($"Updated {count} properties in ProductLine {newProductLine.ProductLineCode}.");
- }
-
- private async Task OnRowRemovedAsync(ProductLine productLine) {
- int count = await genericController.RemoveAsync(productLine);
- Console.WriteLine($"Removed {count} properties and ProductLine {productLine.ProductLineCode}.");
- }
-
- private async Task ResolveProductAsync(ProductLine newProductLine) {
- newProductLine.DataModificationByUser = "Gremlin Blazor Server GUI";
- newProductLine.DataVersionNumber++;
- newProductLine.Products = await genericController.GetAllAsync(p => p.ProductLineCode == newProductLine.ProductLineCode);
- return newProductLine;
- }
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/ProductLines.razor.cs b/Gremlin_BlazorServer/Pages/ProductLines.razor.cs
new file mode 100644
index 0000000..a8fde31
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/ProductLines.razor.cs
@@ -0,0 +1,61 @@
+using Blazorise.DataGrid;
+using Gremlin_BlazorServer.Data.EntityClasses;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using System.Security.Claims;
+
+namespace Gremlin_BlazorServer.Pages;
+
+public partial class ProductLines {
+ [CascadingParameter]
+ private Task? authenticationStateTask { get; set; }
+
+ private IList? productLines;
+ private ProductLine? selectedProductLine;
+ protected override async Task OnParametersSetAsync() {
+ if (authenticationStateTask != null) {
+ ClaimsPrincipal user = (await authenticationStateTask).User;
+ if (user.Identity is { IsAuthenticated: true }) {
+ productLines = await genericController.GetAllAsync();
+ }
+
+ await base.OnInitializedAsync();
+ }
+ }
+
+ private async Task OnSelectedProductLineChanged(ProductLine _selectedProductLine) {
+ if (_selectedProductLine != null) {
+ await ApplicationLoadingIndicatorService.Show();
+ selectedProductLine = await genericController.GetAsync(pL => pL.ProductLineCode == _selectedProductLine.ProductLineCode, "Products");
+ await ApplicationLoadingIndicatorService.Hide();
+ }
+ }
+
+ private async Task OnRowInsertedAsync(SavedRowItem> productLine) {
+ ProductLine newProductLine = await ResolveProductAsync(productLine.Item);
+ if (newProductLine.ProductLineCode == null)
+ return;
+ int count = await genericController.InsertAsync(newProductLine);
+ Console.WriteLine($"Inserted {count} properties for new ProductLine {newProductLine.ProductLineCode}.");
+ }
+
+ private async Task OnRowUpdatedAsync(SavedRowItem> productLine) {
+ ProductLine newProductLine = await ResolveProductAsync(productLine.Item);
+ if (newProductLine.ProductLineCode == null)
+ return;
+ int count = await genericController.UpdateAsync(productLine.Item);
+ Console.WriteLine($"Updated {count} properties in ProductLine {newProductLine.ProductLineCode}.");
+ }
+
+ private async Task OnRowRemovedAsync(ProductLine productLine) {
+ int count = await genericController.RemoveAsync(productLine);
+ Console.WriteLine($"Removed {count} properties and ProductLine {productLine.ProductLineCode}.");
+ }
+
+ private async Task ResolveProductAsync(ProductLine newProductLine) {
+ newProductLine.DataModificationByUser = "Gremlin Blazor Server GUI";
+ newProductLine.DataVersionNumber++;
+ newProductLine.Products = await genericController.GetAllAsync(p => p.ProductLineCode == newProductLine.ProductLineCode);
+ return newProductLine;
+ }
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Products.razor b/Gremlin_BlazorServer/Pages/Products.razor
index 6f1c87f..3a95570 100644
--- a/Gremlin_BlazorServer/Pages/Products.razor
+++ b/Gremlin_BlazorServer/Pages/Products.razor
@@ -115,37 +115,3 @@
-@code {
- [CascadingParameter] private Task? authenticationStateTask { get; set; }
-
- IList? products;
- Product? selectedProduct;
-
- protected override async Task OnInitializedAsync()
- {
- if (authenticationStateTask != null)
- {
- ClaimsPrincipal user = (await authenticationStateTask).User;
-
- if (user.Identity is { IsAuthenticated: true })
- {
-
- await ApplicationLoadingIndicatorService.Show();
- products = await genericController.GetAllAsync();
- await ApplicationLoadingIndicatorService.Hide();
- }
-
- await base.OnInitializedAsync();
- }
- }
-
- private async Task OnSelectedProductChanged(Product _selectedProduct) {
- selectedProduct = _selectedProduct;
- selectedProduct.CustomDescription =
- await genericController.GetAsync(
- cD => cD.ProductNumber.Equals(selectedProduct.ProductNumber)
- && cD.OptionNumber.Equals(selectedProduct.OptionNumber)
- );
- }
-
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Products.razor.cs b/Gremlin_BlazorServer/Pages/Products.razor.cs
new file mode 100644
index 0000000..cba56a9
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/Products.razor.cs
@@ -0,0 +1,31 @@
+using Gremlin_BlazorServer.Data.EntityClasses;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
+using System.Security.Claims;
+
+namespace Gremlin_BlazorServer.Pages;
+
+public partial class Products {
+ [CascadingParameter]
+ private Task? authenticationStateTask { get; set; }
+
+ private IList? products;
+ private Product? selectedProduct;
+ protected override async Task OnInitializedAsync() {
+ if (authenticationStateTask != null) {
+ ClaimsPrincipal user = (await authenticationStateTask).User;
+ if (user.Identity is { IsAuthenticated: true }) {
+ await ApplicationLoadingIndicatorService.Show();
+ products = await genericController.GetAllAsync();
+ await ApplicationLoadingIndicatorService.Hide();
+ }
+
+ await base.OnInitializedAsync();
+ }
+ }
+
+ private async Task OnSelectedProductChanged(Product _selectedProduct) {
+ selectedProduct = _selectedProduct;
+ selectedProduct.CustomDescription = await genericController.GetAsync(cD => cD.ProductNumber.Equals(selectedProduct.ProductNumber) && cD.OptionNumber.Equals(selectedProduct.OptionNumber));
+ }
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor b/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor
index efd69c3..d54f26d 100644
--- a/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor
+++ b/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor
@@ -181,8 +181,6 @@
@@ -190,43 +188,13 @@
+
-
-
- @if (selectedLineItem != null && customDescriptionOfSelectedLineItem != null) {
-
-
-
CustomDescription
-
-
-
- ProductNumber
- @customDescriptionOfSelectedLineItem.ProductNumber
-
-
- OptionNumber
- @customDescriptionOfSelectedLineItem.OptionNumber
-
-
- Heading
- @customDescriptionOfSelectedLineItem.Heading
-
-
- DescriptionText
- @customDescriptionOfSelectedLineItem.DescriptionText
-
-
-
-
- }
}
@if (quote.LineItems == null) {
@@ -301,250 +269,3 @@
-@code {
- [CascadingParameter] private Task? authenticationStateTask { get; set; }
- [Inject] public IModalService modalService { get; set; }
-
- private IList? contacts;
- private Quote quote = new();
- private Contact? selectedContact;
- private LineItem? selectedLineItem;
- private CustomDescription? customDescriptionOfSelectedLineItem;
- 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 bool debug;
-
- private bool modalCustomDescriptionVisible;
- private CustomDescription? newCustomDescription;
-
- public Task ShowCustomDescriptionModal() {
- return modalService.Show(builder => { builder.Add(parameter => parameter.customDescription, newCustomDescription); });
- }
-
- 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();
- await ApplicationLoadingIndicatorService.Hide();
- quote = await GenerateNewQuote(quote, "Woitschetzki");
- }
- }
- await base.OnInitializedAsync();
- }
-
- private async Task GenerateNewQuote(Quote _quote, string salesRepLastName) {
- if (_quote == null) return new();
-
- _quote.SalesRep = await genericController.GetAsync(c => c.LastName.Equals(salesRepLastName), "Account");
-
- Quote? lastQuote = genericController.GetLast();
- if (lastQuote != null)
- {
- _quote.QuoteId = lastQuote.QuoteId + 1;
- }
- else
- {
- _quote.QuoteId = 1;
- }
-
- if (_quote.SalesRep != null) {
- _quote.QuotationNumber = _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}"
- };
- }
- else {
- _quote.QuotationNumber = $"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(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!");
- List? suggestedCustomDescriptions = await SuggestCustomDescriptions(quote.LineItems[i]);
-
- //TODO generate new CustomDescription
- newCustomDescription = new() {
- ProductNumber = quote.LineItems[i].ProductNumber,
- OptionNumber = quote.LineItems[i].OptionNumber,
- Heading = quote.LineItems[i].SapShortDescription,
- CoverletterText = quote.LineItems[i].SapShortDescription,
- DescriptionText = quote.LineItems[i].SapLongDescription
- };
- await ShowCustomDescriptionModal();
- }
- quote.LineItems[i].CustomDescription = newCustomDescription;
- }
-
- }
- }
- catch (Exception exc) {
- Console.WriteLine(exc.Message);
- }
- finally {
- if (quote.Recipient != null) lineItemsNotReady = false;
- StateHasChanged();
- }
- }
-
- private async Task?> SuggestCustomDescriptions(LineItem lineItem) {
- IList? fromProductNumber = await genericController.GetAllAsync(cD => cD.ProductNumber.Equals(lineItem.ProductNumber, StringComparison.Ordinal));
- IList? fromOptionNumber = await genericController.GetAllAsync(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();
- }
-
- 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 = selectedContact;
- quote.Recipient.Account = await genericController.GetAsync(account => account.AccountId.Equals(quote.Recipient.AccountId));
- if (quote.LineItems != null) lineItemsNotReady = false;
-
- }
-
- private async Task OnSave() {
- 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 void OnOpenPdfApp()
- {
- PdfService.OpenPdfWithOkular(quote);
-
- }
-
- private async Task OnOpenPdfNewTab() {
- await jSRuntime.InvokeVoidAsync("OpenNewTab", $"quotes/{url}");
-
- }
-
- private void OnDescriptionChanged(string description) {
- quote.Description = description;
-
- }
-
- private void OnQuotationNumberChanged(string quotationNumber) {
- quote.QuotationNumber = quotationNumber;
-
- }
-
- private void OnValidForChanged(string validFor) {
- quote.ValidFor = byte.Parse(validFor);
-
- }
-
- private void OnVATChanged(string vat) {
- quote.Vat = float.Parse(vat);
-
- }
-
- private void OnIsPriceInformationChanged(bool isPriceInformation) {
- quote.IsPriceInformation = isPriceInformation;
-
- }
-
- private void OnShowBruttoChanged(bool onShowBrutto) {
- quote.ShowBrutto = onShowBrutto;
-
- }
-
- private void OnShowDiscountsChanged(bool showDiscount) {
- quote.ShowDiscounts = showDiscount;
-
- }
-
- private void OnShowSinglePricesChanged(bool showSinglePrices) {
- quote.ShowSinglePrices = showSinglePrices;
-
- }
-
- private void OnWarrantyChanged(string warranty) {
- quote.Warranty = int.Parse(warranty);
- }
-
- private void OnCancel() {
- navigationManager.NavigateTo("Quotes/QuoteIndex");
- }
-
- private async Task OnSelectedLineItemChanged(LineItem lI) {
- selectedLineItem = lI;
- customDescriptionOfSelectedLineItem =
- await genericController.GetAsync(cD => cD.ProductNumber.Equals(lI.ProductNumber) && cD.OptionNumber.Equals(lI.OptionNumber));
-
- }
-
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor.cs b/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor.cs
new file mode 100644
index 0000000..b6ebdc2
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor.cs
@@ -0,0 +1,193 @@
+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? authenticationStateTask { get; set; }
+
+ [Inject]
+ public IModalService? modalService { get; set; }
+
+ private IList? 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? suggestedCustomDescriptions;
+ private CustomDescription? newCustomDescription;
+ public Task ShowCustomDescriptionModal() => modalService.Show(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();
+ await ApplicationLoadingIndicatorService.Hide();
+ quote = await GenerateNewQuote(quote, "Woitschetzki");
+ }
+ }
+
+ await base.OnInitializedAsync();
+ }
+
+ private async Task GenerateNewQuote(Quote _quote, string salesRepLastName) {
+ if (_quote == null)
+ return new();
+ _quote.SalesRep = await genericController.GetAsync(c => c.LastName.Equals(salesRepLastName), "Account");
+ Quote? lastQuote = genericController.GetLast();
+ _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";
+ 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(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]);
+ //TODO generate new CustomDescription
+ newCustomDescription = new() {
+ ProductNumber = quote.LineItems[i].ProductNumber,
+ OptionNumber = quote.LineItems[i].OptionNumber,
+ Heading = quote.LineItems[i].SapShortDescription,
+ DescriptionText = quote.LineItems[i].SapLongDescription
+ };
+ await ShowCustomDescriptionModal();
+ }
+
+ quote.LineItems[i].CustomDescription = newCustomDescription;
+ }
+ }
+ }
+ catch (Exception exc) {
+ Console.WriteLine(exc.Message);
+ }
+ finally {
+ if (quote.Recipient != null)
+ lineItemsNotReady = false;
+ StateHasChanged();
+ }
+ }
+
+ private async Task?> SuggestCustomDescriptions(LineItem lineItem) {
+ //IList? fromProductNumber = await genericController.GetAllAsync(cD => cD.ProductNumber.Equals(lineItem.ProductNumber, StringComparison.Ordinal));
+ IList? fromOptionNumber = new List();
+ if (lineItem.OptionNumber != "")
+ fromOptionNumber = await genericController.GetAllAsync(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();
+ }
+
+ 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 = selectedContact;
+ quote.Recipient.Account = await genericController.GetAsync(account => account.AccountId.Equals(quote.Recipient.AccountId));
+ if (quote.LineItems != null)
+ lineItemsNotReady = false;
+ }
+
+ private async Task OnSave() {
+ 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 void OnOpenPdfApp() => PdfService.OpenPdfWithOkular(quote);
+
+ private async Task OnOpenPdfNewTab() => await jSRuntime.InvokeVoidAsync("OpenNewTab", $"quotes/{url}");
+
+ private void OnDescriptionChanged(string description) => quote.Description = description;
+
+ private void OnQuotationNumberChanged(string quotationNumber) => quote.QuotationNumber = quotationNumber;
+
+ private void OnValidForChanged(string validFor) => quote.ValidFor = byte.Parse(validFor);
+
+ private void OnVATChanged(string vat) => quote.Vat = float.Parse(vat);
+
+ private void OnIsPriceInformationChanged(bool isPriceInformation) => quote.IsPriceInformation = isPriceInformation;
+
+ private void OnShowBruttoChanged(bool onShowBrutto) => quote.ShowBrutto = onShowBrutto;
+
+ private void OnShowDiscountsChanged(bool showDiscount) => quote.ShowDiscounts = showDiscount;
+
+ private void OnShowSinglePricesChanged(bool showSinglePrices) => quote.ShowSinglePrices = showSinglePrices;
+
+ private void OnWarrantyChanged(string warranty) => quote.Warranty = int.Parse(warranty);
+
+ private void OnCancel() => navigationManager.NavigateTo("Quotes/QuoteIndex");
+}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor b/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor
index a3a39f8..fa836a1 100644
--- a/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor
+++ b/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor
@@ -177,46 +177,3 @@
-@code {
- [CascadingParameter] private Task? authenticationStateTask { get; set; }
-
- private IList? 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();
- }
- }
- await base.OnInitializedAsync();
- }
-
- private async Task OnSelectedQuoteChanged(Quote _selectedQuote) {
- selectedQuote = _selectedQuote;
- selectedQuote.Recipient = await genericController.GetAsync(c => c.ContactId.Equals(selectedQuote.ContactId));
- if (selectedQuote.Recipient != null && selectedQuote != null) {
- selectedQuote = await genericController.GetAsync(c => c.QuoteId.Equals(_selectedQuote.QuoteId), "Recipient", "LineItems");
- selectedQuote.Recipient.Account = await genericController.GetAsync(a => a.AccountId.Equals(selectedQuote.Recipient.AccountId));
- }
- //selectedQuote.LineItems = await genericController.GetAllAsync(lI => lI.Quote.Equals(selectedQuote));
- return;
- }
-
- private void OnCreateNewQuote() {
- navigationManager.NavigateTo("Quotes/QuoteAdd");
- }
-
- private Task OnSelectedTabChanged(string _selectedTab) {
- selectedTab = _selectedTab;
- return Task.CompletedTask;
- }
-
-}
\ No newline at end of file
diff --git a/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor.cs b/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor.cs
new file mode 100644
index 0000000..e496d2e
--- /dev/null
+++ b/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor.cs
@@ -0,0 +1,48 @@
+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? authenticationStateTask { get; set; }
+
+ private IList? 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();
+ }
+ }
+
+ await base.OnInitializedAsync();
+ }
+
+ private async Task OnSelectedQuoteChanged(Quote _selectedQuote) {
+ selectedQuote = _selectedQuote;
+ selectedQuote.Recipient = await genericController.GetAsync(c => c.ContactId.Equals(selectedQuote.ContactId));
+ if (selectedQuote.Recipient != null && selectedQuote != null) {
+ selectedQuote = await genericController.GetAsync(c => c.QuoteId.Equals(_selectedQuote.QuoteId), "Recipient", "LineItems");
+ selectedQuote.Recipient.Account = await genericController.GetAsync(a => a.AccountId.Equals(selectedQuote.Recipient.AccountId));
+ }
+
+ //selectedQuote.LineItems = await genericController.GetAllAsync(lI => lI.Quote.Equals(selectedQuote));
+ return;
+ }
+
+ private void OnCreateNewQuote() {
+ navigationManager.NavigateTo("Quotes/QuoteAdd");
+ }
+
+ private Task OnSelectedTabChanged(string _selectedTab) {
+ selectedTab = _selectedTab;
+ return Task.CompletedTask;
+ }
+ }
+}
\ No newline at end of file