diff --git a/Gremlin_BlazorServer/Data/DBClasses/EntityConfiguration.cs b/Gremlin_BlazorServer/Data/DBClasses/EntityConfiguration.cs index 6afba80..2a16e3b 100644 --- a/Gremlin_BlazorServer/Data/DBClasses/EntityConfiguration.cs +++ b/Gremlin_BlazorServer/Data/DBClasses/EntityConfiguration.cs @@ -108,7 +108,7 @@ public class QuoteConfiguration : IEntityTypeConfiguration { // quoteEntity.HasOne(e => e.Recipient).WithMany(c => c.Quotes).HasForeignKey(fk => fk.RecipientId); // quoteEntity.HasOne(e => e.SalesRep).WithMany(sR => sR.Quotes).HasForeignKey(fk => fk.SalesRepId); - // quoteEntity.HasMany(d => d.LineItems).WithOne(p => p.Quote).HasForeignKey(fk => fk.QuoteId); + quoteEntity.HasMany(q => q.LineItems).WithOne(lI => lI.Quote).HasForeignKey(fk => fk.QuoteId); quoteEntity.Property(e => e.QuotationNumber).HasColumnType("VARCHAR(255)").ValueGeneratedOnAdd(); quoteEntity.Property(e => e.QuotationDate).ValueGeneratedOnAdd(); @@ -138,7 +138,7 @@ public class LineItemConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder lineItemEntity) { lineItemEntity.HasKey(e => e.LineItemId); - // lineItemEntity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId); + lineItemEntity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId); // lineItemEntity.HasOne(lI => lI.CustomDescription).WithMany(d => d.LineItems).HasForeignKey(fk => fk.CustomDescriptionId); // lineItemEntity.HasOne(lI => lI.Product).WithMany(p => p.LineItems).HasForeignKey(fK => fK.LineItemId); diff --git a/Gremlin_BlazorServer/Data/EntityClasses/LineItem.cs b/Gremlin_BlazorServer/Data/EntityClasses/LineItem.cs index 59c6fc5..b9a519e 100644 --- a/Gremlin_BlazorServer/Data/EntityClasses/LineItem.cs +++ b/Gremlin_BlazorServer/Data/EntityClasses/LineItem.cs @@ -5,12 +5,12 @@ public class LineItem : IMetadata { public uint LineItemId { get; set; } //foreign keys: - // public uint QuoteId { get; set; } + public uint QuoteId { get; set; } // public uint? ProductId { get; set; } public uint CustomDescriptionId { get; set; } //navigation properties: - // public Quote? Quote { get; set; } + public Quote Quote { get; set; } // public Product? Product { get; set; } // public CustomDescription? CustomDescription { get; set; } @@ -41,4 +41,10 @@ public class LineItem : IMetadata { public DateTime DataValidUntil { get; set; } = DateTime.MaxValue; public string? DataVersionComment { get; set; } public uint DataVersionNumber { get; set; } + + //Constructor + public LineItem(Quote quote) { + QuoteId = quote.QuoteId; + Quote = quote; + } } \ No newline at end of file diff --git a/Gremlin_BlazorServer/Data/EntityClasses/Quote.cs b/Gremlin_BlazorServer/Data/EntityClasses/Quote.cs index ac29f4c..5080d67 100644 --- a/Gremlin_BlazorServer/Data/EntityClasses/Quote.cs +++ b/Gremlin_BlazorServer/Data/EntityClasses/Quote.cs @@ -8,14 +8,13 @@ public class Quote : IMetadata { //foreign keys: public uint RecipientId { get; set; } - public uint SalesRepId { get; set; } // public uint ProductId { get; set; } //navigation properties: public Contact? Recipient { get; set; } public SalesRep? SalesRep { get; set; } - public IList? LineItems { get; set; } + public IList LineItems { get; set; } = new List(); //class properties: public string? QuotationNumber { get; set; } diff --git a/Gremlin_BlazorServer/Pages/LineItems.razor.cs b/Gremlin_BlazorServer/Pages/LineItems.razor.cs index 61deacb..51174f4 100644 --- a/Gremlin_BlazorServer/Pages/LineItems.razor.cs +++ b/Gremlin_BlazorServer/Pages/LineItems.razor.cs @@ -12,7 +12,7 @@ public partial class LineItems { private readonly CultureInfo cultureInfo = new("de-DE"); private readonly IList lineItems=new List(); - private LineItem selectedLineItem = new(); + private LineItem? selectedLineItem; [CascadingParameter] private Task? AuthenticationStateTask { get; set; } protected override async Task OnInitializedAsync() { diff --git a/Gremlin_BlazorServer/Pages/Products.razor b/Gremlin_BlazorServer/Pages/Products.razor index df85859..457a857 100644 --- a/Gremlin_BlazorServer/Pages/Products.razor +++ b/Gremlin_BlazorServer/Pages/Products.razor @@ -2,7 +2,6 @@ @using Gremlin_BlazorServer.Services @using Gremlin_BlazorServer.Data.EntityClasses -@inject GenericController GenericController @inject ILoadingIndicatorService ApplicationLoadingIndicatorService diff --git a/Gremlin_BlazorServer/Pages/QuoteDebug.razor b/Gremlin_BlazorServer/Pages/QuoteDebug.razor index 580e945..535bbec 100644 --- a/Gremlin_BlazorServer/Pages/QuoteDebug.razor +++ b/Gremlin_BlazorServer/Pages/QuoteDebug.razor @@ -1,12 +1,177 @@ @page "/QuoteDebug" -@using Gremlin_BlazorServer.Services +@using System.Globalization @using Gremlin_BlazorServer.Data.EntityClasses -@inject NavigationManager NavigationManager - @if (debug) { - - } +
+ + Quote Debug + + @if (debug) { + + } + +
+ +
+ + Quote Details + + + + + Angebotsname + + + + + + Angebotsnummer + + + + + + Angebotspfad + + " + + + + Gewährleistung (Monate) + + + + + + Angebotsgültigkeit (Tage) + + + + + + Mehrwertsteuer (%) + + + + + + Versandkosten (%) + + + + + + + @if (quote.Recipient is not null) { + + + FirstName + @quote.Recipient.FirstName + + + LastName + @quote.Recipient.LastName + + + AccountName + @quote.Recipient.Account.AccountName + + + Street + @quote.Recipient.Account.Street + + + Zip + @quote.Recipient.Account.Zip.ToString() + + + City + @quote.Recipient.Account.City + + + } + + + Preisinformation + Bruttopreise anzeigen + Einzelpreise ausweisen + Discounts ausweisen + + + + + Listenpreis netto + + + + + + Summe netto + + + + + + Versandkosten + + + + + + Gesamtsumme netto + + + + + + Mehrwertsteuer + + + + + + Gesamtsumme brutto + + + + + + + +
+ +
+ + LineItems + + + + + + + + + + + + + + +
@@ -19,14 +184,4 @@ You're not signed in. Please click on the upper right to either register or log in. -
- -@code { - private const bool debug = true; - private Quote quote = new(); - - private async Task OnSave() { - if (await GenericController.InsertAsync(quote) > 0) - NavigationManager.NavigateTo("Quotes/QuoteIndex"); - } -} \ No newline at end of file +
\ No newline at end of file diff --git a/Gremlin_BlazorServer/Pages/QuoteDebug.razor.cs b/Gremlin_BlazorServer/Pages/QuoteDebug.razor.cs new file mode 100644 index 0000000..f103daa --- /dev/null +++ b/Gremlin_BlazorServer/Pages/QuoteDebug.razor.cs @@ -0,0 +1,54 @@ +using System.Diagnostics; +using System.Globalization; +using System.Security.Claims; +using Gremlin_BlazorServer.Data.EntityClasses; +using Gremlin_BlazorServer.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Authorization; + +namespace Gremlin_BlazorServer.Pages; + +public partial class QuoteDebug { + [CascadingParameter] private Task? AuthenticationStateTask { get; set; } + + private const bool debug = true; + private readonly CultureInfo cultureInfo = new("de-DE"); + + private readonly Quote quote = new(){ + Recipient = GenericController.Get(c => c.ContactId == 1), + SalesRep = GenericController.Get(sR => sR.SalesRepId == 15), + }; + + private LineItem? selectedLineItem; + + protected override async Task OnParametersSetAsync() { + if (AuthenticationStateTask is not null) { + ClaimsPrincipal user = (await AuthenticationStateTask).User; + if (user.Identity is { IsAuthenticated: true }) + quote.LineItems.Add(new(quote)); + } + await base.OnInitializedAsync(); + } + + private async Task OnSave() => Debug.WriteLine(await GenericController.InsertAsync(quote) > 0 ? "Wrote Quote to db." : "Error on writing Quote to db!"); + + private Task OnDescriptionChanged() => throw new NotImplementedException(); + + private Task OnQuotationNumberChanged() => throw new NotImplementedException(); + + private Task OnWarrantyChanged() => throw new NotImplementedException(); + + private Task OnValidForChanged() => throw new NotImplementedException(); + + private Task OnVATChanged() => throw new NotImplementedException(); + + private Task OnIsPriceInformationChanged() => throw new NotImplementedException(); + + private Task OnShowBruttoChanged() => throw new NotImplementedException(); + + private Task OnShowSinglePricesChanged() => throw new NotImplementedException(); + + private Task OnShowDiscountsChanged() => throw new NotImplementedException(); + + private Task OnSelectedLineItemChanged() => throw new NotImplementedException(); +} \ No newline at end of file diff --git a/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor.cs b/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor.cs index 01e2f6c..4778966 100644 --- a/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor.cs +++ b/Gremlin_BlazorServer/Pages/Quotes/QuoteAdd.razor.cs @@ -26,7 +26,7 @@ public partial class QuoteAdd { private Quote quote = new(); private Contact recipient = new(); private SalesRep salesRep = new(); - private LineItem selectedLineItem = new(); + private LineItem? selectedLineItem; // private List? suggestedCustomDescriptions; private bool texNotReady = true; diff --git a/Gremlin_BlazorServer/Services/QuoteHandling.cs b/Gremlin_BlazorServer/Services/QuoteHandling.cs index ac2ffd6..eb3babd 100644 --- a/Gremlin_BlazorServer/Services/QuoteHandling.cs +++ b/Gremlin_BlazorServer/Services/QuoteHandling.cs @@ -22,7 +22,7 @@ public class QuoteHandling { try { quote = ResetTotals(quote); - quote.LineItems = ReadLineItemsFromClipboard(clipboard); + quote.LineItems = ReadLineItemsFromClipboard(quote, clipboard); quote.QuoteContains3Pp = DoesContains(quote, "3PP"); quote.QuoteContainsRb = DoesContains(quote, "RB"); @@ -53,15 +53,15 @@ public class QuoteHandling { } } - private static List ReadLineItemsFromClipboard(string clipboard) { + private static List ReadLineItemsFromClipboard(Quote quote, string clipboard) { //Zeilen aufteilen IEnumerable clipboardLines = clipboard.Split(Environment.NewLine.ToCharArray()); List clipboardList = (from clipboardLine in clipboardLines where clipboardLine != "" select clipboardLine.Split('\t')).ToList(); - List lineItems = ParseClipboardList(clipboardList).Result; + List lineItems = ParseClipboardList(quote, clipboardList).Result; return lineItems; } - private static Task> ParseClipboardList(List lineItemStrings) { + private static Task> ParseClipboardList(Quote quote, List lineItemStrings) { List lineItems = new(); CultureInfo cultureInfoUs = new("en-US"); @@ -73,7 +73,7 @@ public class QuoteHandling { if (lineItemString[0] == "#") continue; //Dateiinhalt in Klasse schreiben - LineItem lineItem = new() { + LineItem lineItem = new(quote) { Position = ushort.Parse(lineItemString[0]), ProductNumber = lineItemString[1], OptionNumber = lineItemString[2], diff --git a/Gremlin_BlazorServer/Shared/BlazoriseNavMenu.razor b/Gremlin_BlazorServer/Shared/BlazoriseNavMenu.razor index ed550ee..366b0b6 100644 --- a/Gremlin_BlazorServer/Shared/BlazoriseNavMenu.razor +++ b/Gremlin_BlazorServer/Shared/BlazoriseNavMenu.razor @@ -87,6 +87,13 @@ LineItems + + + + + QuoteDebug + +