From ec971c0b008b2654764f30ff09d35a60ac35cc42 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Fri, 4 Aug 2023 13:34:46 +0200 Subject: [PATCH] working new models for product detail view and refactor to fit --- .../CustomerInventoryListComponent.razor | 5 +- .../ProductPriceListComponent.razor | 12 +--- .../ProductPriceListComponent.razor.cs | 10 ++- .../CountryCatalogRepository.cs | 62 ++++++++++--------- .../ICountryCatalogRepository.cs | 36 ++++++----- .../Local.Services/CabinetDrawerService.cs | 53 +++++++++------- .../Models/{SelectedSku.cs => ItemSelect.cs} | 6 +- .../CustomerInventoryListOverlay.razor | 4 +- .../CustomerInventoryListOverlay.razor.cs | 3 +- .../CustomerInventoryReorderOverlay.razor | 8 +-- .../CustomerInventoryReorderOverlay.razor.cs | 12 ++-- .../CatalogPagedOverlay.razor | 3 +- .../CatalogPagedOverlay.razor.cs | 8 +-- .../Pages/AdvisorActivityCreatePage.razor | 2 +- .../Pages/AdvisorActivityCreatePage.razor.cs | 12 ++-- .../AdvisorCustomerInventoryListPage.razor | 2 +- .../Pages/CatalogCountryProductPage.razor | 2 +- .../Pages/CatalogCountryProductPage.razor.cs | 7 +-- .../Pages/OfficeOrderCreatePage.razor.cs | 10 +-- Wonky.Client/wwwroot/appsettings.json | 2 +- Wonky.Entity/Views/ProductDetailView.cs | 38 ++++++++++++ .../Views/ProductInventoryItemView.cs | 1 + 22 files changed, 174 insertions(+), 124 deletions(-) rename Wonky.Client/Models/{SelectedSku.cs => ItemSelect.cs} (92%) create mode 100644 Wonky.Entity/Views/ProductDetailView.cs diff --git a/Wonky.Client/Components/CustomerInventoryListComponent.razor b/Wonky.Client/Components/CustomerInventoryListComponent.razor index e24ad16c..35ec2ba1 100644 --- a/Wonky.Client/Components/CustomerInventoryListComponent.razor +++ b/Wonky.Client/Components/CustomerInventoryListComponent.razor @@ -84,7 +84,10 @@
- @product.Description + +
diff --git a/Wonky.Client/Components/ProductPriceListComponent.razor b/Wonky.Client/Components/ProductPriceListComponent.razor index 94d632bf..5ea09682 100644 --- a/Wonky.Client/Components/ProductPriceListComponent.razor +++ b/Wonky.Client/Components/ProductPriceListComponent.razor @@ -36,16 +36,10 @@ onerror="this.onerror=null;this.src='@(_config.AssetUrl)/images/no-image.png?height=100'" alt="@salesItem.Name"/> - - @salesItem.Name - + @salesItem.Name @salesItem.ShortName - - @salesItem.Sku - - - @salesItem.BoxSize - + @salesItem.Sku + @salesItem.BoxSize
- + @if (Working) { diff --git a/Wonky.Client/Pages/CatalogCountryProductPage.razor b/Wonky.Client/Pages/CatalogCountryProductPage.razor index 59d99534..5b68f11f 100644 --- a/Wonky.Client/Pages/CatalogCountryProductPage.razor +++ b/Wonky.Client/Pages/CatalogCountryProductPage.razor @@ -1,6 +1,6 @@ @using Wonky.Client.Components @using System.Text.Json -@page "/catalog/{CountryCode}/{sku}" +@page "/catalog/item/{SalesItemId}"

CatalogCountryProductPage

diff --git a/Wonky.Client/Pages/CatalogCountryProductPage.razor.cs b/Wonky.Client/Pages/CatalogCountryProductPage.razor.cs index ac5b6bf3..766902c3 100644 --- a/Wonky.Client/Pages/CatalogCountryProductPage.razor.cs +++ b/Wonky.Client/Pages/CatalogCountryProductPage.razor.cs @@ -15,11 +15,10 @@ public partial class CatalogCountryProductPage [Inject] public ICountryCatalogRepository Catalog { get; set; } // ############################################################## - [Parameter] public string CountryCode { get; set; } = ""; - [Parameter] public string Sku { get; set; } = ""; + [Parameter] public string SalesItemId { get; set; } = ""; // ############################################################## - private SalesItemView _item = new(); + private ProductDetailView _item = new(); private bool _working = true; protected override async Task OnInitializedAsync() @@ -27,7 +26,7 @@ public partial class CatalogCountryProductPage Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - _item = await Catalog.GetSalesItemSku(CountryCode, Sku); + _item = await Catalog.GetProductDetailView(SalesItemId); _working = false; } } \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs index 3669681c..9692a4e8 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs @@ -205,15 +205,15 @@ public partial class OfficeOrderCreatePage : IDisposable } - private async Task PriceListCallback(SelectedSku sku) + private async Task PriceListCallback(ItemSelect selectedItem) { // get selected item - if (string.IsNullOrWhiteSpace(sku.ItemId)) + if (string.IsNullOrWhiteSpace(selectedItem.ItemNo)) return; - SelectedItem = await Catalog.GetSalesItemId(CountryCode, sku.ItemId); + SelectedItem = await Catalog.GetSalesItemSku(CountryCode, selectedItem.ItemNo); ShowItem = true; - Price = sku.Rate; - Quantity = sku.Quantity; + Price = selectedItem.Rate; + Quantity = selectedItem.Quantity; StateHasChanged(); } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 54c5adfe..4a80d975 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Online", - "version": "203.0", + "version": "205.0", "rc": true, "sandBox": true, "image": "grumpy-coder.png", diff --git a/Wonky.Entity/Views/ProductDetailView.cs b/Wonky.Entity/Views/ProductDetailView.cs new file mode 100644 index 00000000..e81f33a0 --- /dev/null +++ b/Wonky.Entity/Views/ProductDetailView.cs @@ -0,0 +1,38 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Collections.Generic; + +namespace Wonky.Entity.Views; + +public class ProductDetailView +{ + public string Name { get; set; } = ""; + public string Sku { get; set; } = ""; + public string VendorItemNo { get; set; } = ""; + public string ShortName { get; set; } = ""; + public string PictureLink { get; set; } = ""; + public string ProductGroup { get; set; } = ""; + public bool Discontinued { get; set; } + public int BoxSize { get; set; } + public List Documents { get; set; } = new(); +} + +public class DocumentView +{ + public string Name { get; set; } = ""; + public string Description { get; set; } = ""; + public string DocumentTypeEnum { get; set; } = ""; +} \ No newline at end of file diff --git a/Wonky.Entity/Views/ProductInventoryItemView.cs b/Wonky.Entity/Views/ProductInventoryItemView.cs index 3ae7c600..307b8f37 100644 --- a/Wonky.Entity/Views/ProductInventoryItemView.cs +++ b/Wonky.Entity/Views/ProductInventoryItemView.cs @@ -29,4 +29,5 @@ public class ProductInventoryItemView public string LastInvoiceDate { get; set; } = ""; public string Sku { get; set; } = ""; public string VendorItemNo { get; set; } = ""; + public string SalesItemId { get; set; } = ""; } \ No newline at end of file