diff --git a/FruitBank.Common.Server/FruitBank.Common.Server.csproj b/FruitBank.Common.Server/FruitBank.Common.Server.csproj index 066befd..b739bec 100644 --- a/FruitBank.Common.Server/FruitBank.Common.Server.csproj +++ b/FruitBank.Common.Server/FruitBank.Common.Server.csproj @@ -1,56 +1,53 @@  - - net9.0 - enable - enable - true - + + net9.0 + enable + enable + true + - - - - - - - - - + + + + + + + + + - - - + + + - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.dll - - - ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll - - - C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.8\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll - - - ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll - - - ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Nop.Core.dll - - - ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll - + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.dll + + + ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll + + + C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.9\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll + + + ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll + + + ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Nop.Core.dll + - + - - - + + + diff --git a/FruitBank.Common/Entities/ShippingItem.cs b/FruitBank.Common/Entities/ShippingItem.cs index d409dcd..1430196 100644 --- a/FruitBank.Common/Entities/ShippingItem.cs +++ b/FruitBank.Common/Entities/ShippingItem.cs @@ -1,9 +1,12 @@ using AyCode.Core.Interfaces; using FruitBank.Common.Interfaces; +using LinqToDB; using LinqToDB.Mapping; using Mango.Nop.Core.Entities; using Nop.Core.Domain.Customers; using Nop.Core.Domain.Orders; +using System.ComponentModel.DataAnnotations; +using DataType = LinqToDB.DataType; namespace FruitBank.Common.Entities; @@ -17,13 +20,24 @@ public class ShippingItem : MgEntityBase, IShippingItem public int ShippingDocumentId { get; set; } public string Name { get; set; } + [Column(DataType = DataType.DecFloat)] public double NetWeight { get; set; } + [Column(DataType = DataType.DecFloat)] public double GrossWeight { get; set; } + + [Column(DataType = DataType.DecFloat, CanBeNull = true)] + [Required] + [Range(1, 100000, ErrorMessage = "The MeasuredNetWeight value should be a number between 1 and 100,000.")] public double? MeasuredNetWeight { get; set; } + + [Column(DataType = DataType.DecFloat, CanBeNull = true)] + [Required] + [Range(1, 100000, ErrorMessage = "The MeasuredGrossWeight value should be a number between 1 and 100,000.")] public double? MeasuredGrossWeight { get; set; } + public bool IsMeasured { get; set; } - [Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(ShippingDocument.Id))] + [LinqToDB.Mapping.Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(ShippingDocument.Id))] public ShippingDocument? ShippingDocument { get; set; } diff --git a/FruitBank.Common/FruitBank.Common.csproj b/FruitBank.Common/FruitBank.Common.csproj index 4d91e90..ee2c594 100644 --- a/FruitBank.Common/FruitBank.Common.csproj +++ b/FruitBank.Common/FruitBank.Common.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj b/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj index b968719..8a08473 100644 --- a/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj +++ b/FruitBankHybrid.Shared.Common/FruitBankHybrid.Shared.Common.csproj @@ -9,7 +9,7 @@ - + diff --git a/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs b/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs index b5a2d9c..c6ec44f 100644 --- a/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs +++ b/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs @@ -143,6 +143,8 @@ namespace FruitBankHybrid.Shared.Tests Assert.IsNotNull(shippingItem); Assert.IsTrue(shippingItem.Id == shippingItemeId); + Assert.IsTrue(shippingItem.NetWeight > 0, "NetWeight == 0"); + Assert.IsTrue(shippingItem.GrossWeight > 0, "GrossWeight == 0"); return shippingItem; } @@ -155,10 +157,12 @@ namespace FruitBankHybrid.Shared.Tests var newName = GetFixtureName(shippingItem.Name); shippingItem.Name = newName; + //shippingItem.MeasuredGrossWeight = 5; await _signalRClient.UpdateShippingItem(shippingItem); shippingItem = await GetShippingItemByIdTest(shippingItemId); Assert.IsTrue(shippingItem.Name == newName); + //Assert.IsTrue(shippingItem.MeasuredGrossWeight is 5); shippingItem.Name = GetOriginalName(shippingItem.Name); await _signalRClient.UpdateShippingItem(shippingItem); diff --git a/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj b/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj index ed30024..bf42a1d 100644 --- a/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj +++ b/FruitBankHybrid.Shared.Tests/FruitBankHybrid.Shared.Tests.csproj @@ -45,4 +45,31 @@ + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj b/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj index 095a2f9..5025ca6 100644 --- a/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj +++ b/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj @@ -14,9 +14,9 @@ - - - + + + diff --git a/FruitBankHybrid.Shared/Pages/Login.razor b/FruitBankHybrid.Shared/Pages/Login.razor index 3037348..8405fdc 100644 --- a/FruitBankHybrid.Shared/Pages/Login.razor +++ b/FruitBankHybrid.Shared/Pages/Login.razor @@ -3,51 +3,46 @@

Bejelentkezés

-
-
+ + - +
- @context.DataItem.Email + @ctxCombo.DataItem.Email
- @context.DataItem.FullName - @context.DataItem.Email + @ctxCombo.DataItem.FullName + @ctxCombo.DataItem.Email
-
+ -
+ + + + + + + + +
+
+ @(LoginModelResponse?.CustomerDto == null ? LoginModelResponse?.ErrorMessage : LoginModelResponse?.CustomerDto.FullName)
- -
-
- -
-
- -
-
- @(LoginModelResponse?.CustomerDto == null ? LoginModelResponse?.ErrorMessage : LoginModelResponse?.CustomerDto.FullName) -
-
-
\ No newline at end of file diff --git a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor index 1e8e6c5..a523bff 100644 --- a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor +++ b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor @@ -5,56 +5,93 @@ @using FruitBankHybrid.Shared.Services @using Mango.Nop.Core.Dtos -

Bejövő mérés

-
-
- - - -
-
- @($"{context.DataItem.ShippingDate} [{context.DataItem.LicencePlate}]") - @* @(string.Join("; ", context.DataItem?.ShippingDocuments?.Select(x => x.Partner?.Name ?? string.Empty))) *@ +
+ + + Összes szállítmány listázása + + + + + +
+
+ @($"{ctxCombo.DataItem.ShippingDate} [{ctxCombo.DataItem.LicencePlate}]") + @* @(string.Join("; ", context.DataItem?.ShippingDocuments?.Select(x => x.Partner?.Name ?? string.Empty))) *@ +
-
- - -
+ + + -
- - -
+ + + -
- - -
+ + + +
-
+
+ @if (SelectedShippingItem != null) + { + + + + + + + + + + + + + + + + + + + + + + + + + + } +
+ +@* +
@@ -62,7 +99,7 @@
-
+
    @foreach (var m in _messages) @@ -71,4 +108,5 @@ }
-
\ No newline at end of file +
+ *@ \ No newline at end of file diff --git a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs index f113497..25e7054 100644 --- a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs +++ b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs @@ -17,6 +17,7 @@ using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Components.Forms; using static System.Net.Mime.MediaTypeNames; using static System.Runtime.InteropServices.JavaScript.JSType; using ILogger = FruitBank.Common.Loggers.ILogger; @@ -35,6 +36,9 @@ namespace FruitBankHybrid.Shared.Pages private ShippingDocument? SelectedShippingDocument { get; set; } private ShippingItem? SelectedShippingItem { get; set; } + protected bool BtnSaveEnabled { get; set; } + protected bool ChkAllShipping { get; set; } + private string _userName = "Partner name"; private string _message = string.Empty; private readonly List<(string User, string Text)> _messages = []; @@ -44,24 +48,118 @@ namespace FruitBankHybrid.Shared.Pages _logger = new LoggerClient(LogWriters.ToArray()); _logger.Info("OnInitializedAsync"); - NotMeasuredShippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? []; - SelectedShipping = NotMeasuredShippings?.FirstOrDefault(); - + await RefreshShippingsFromDb(ChkAllShipping); await base.OnInitializedAsync(); } - public void OnSelectedShippingChanged(SelectedDataItemChangedEventArgs eventArgs) + private async Task RefreshShippingsFromDb(bool getAllShipping) { - SelectedShippingDocument = eventArgs.DataItem.ShippingDocuments?.FirstOrDefault(); - SelectedShippingItem = SelectedShippingDocument?.ShippingItems?.FirstOrDefault(); - + if (getAllShipping) NotMeasuredShippings = await FruitBankSignalRClient.GetShippings() ?? []; + else NotMeasuredShippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? []; + + SelectedShipping = NotMeasuredShippings.FirstOrDefault(); } - public void OnSelectedShippingDocumentChanged(SelectedDataItemChangedEventArgs eventArgs) + private async Task OnChkAllShippingChanged(bool value) + { + ChkAllShipping = value; + await RefreshShippingsFromDb(ChkAllShipping); + } + + private void OnSelectedShippingChanged(SelectedDataItemChangedEventArgs eventArgs) + { + SelectedShippingDocument = eventArgs.DataItem?.ShippingDocuments?.FirstOrDefault(); + } + + private void OnSelectedShippingDocumentChanged(SelectedDataItemChangedEventArgs eventArgs) { SelectedShippingItem = eventArgs.DataItem?.ShippingItems?.FirstOrDefault(); } + private async Task OnSelectedShippingItemChanged(SelectedDataItemChangedEventArgs eventArgs) + { + BtnSaveEnabled = false; + + if (eventArgs.DataItem == null) + { + SelectedShippingItem = null; + return; + } + + await RefreshSelectedShippingItemMeasuredValuesFromDb(eventArgs.DataItem.Id); + } + + private async Task RefreshSelectedShippingItemMeasuredValuesFromDb(int shippingItemId) + { + RefreshSelectedShippingItemMeasuredValuesFromDb(await FruitBankSignalRClient.GetShippingItemById(shippingItemId)); + } + + private void RefreshSelectedShippingItemMeasuredValuesFromDb(ShippingItem? shippingItemFromDb) + { + if (SelectedShippingItem == null || shippingItemFromDb == null) return; + + SelectedShippingItem.MeasuredNetWeight = shippingItemFromDb.MeasuredNetWeight; + SelectedShippingItem.MeasuredGrossWeight = shippingItemFromDb.MeasuredGrossWeight; + SelectedShippingItem.IsMeasured = shippingItemFromDb.IsMeasured; + + if (SelectedShippingItem is { IsMeasured: true }) + { + SelectedShippingDocument?.ShippingItems?.Remove(SelectedShippingItem); + SelectedShippingItem = SelectedShippingDocument?.ShippingItems?.FirstOrDefault(); + } + + StateHasChanged(); + } + + private async Task UpdateShippingItem(ShippingItem? shippingItem) + { + if (shippingItem is { MeasuredGrossWeight: > 0, MeasuredNetWeight: > 0 }) + { + BtnSaveEnabled = false; + + shippingItem.IsMeasured = shippingItem is { MeasuredGrossWeight: > 0, MeasuredNetWeight: > 0 }; + RefreshSelectedShippingItemMeasuredValuesFromDb(await FruitBankSignalRClient.UpdateShippingItem(shippingItem)); + } + } + + private async Task HandleValidSubmit() + { + await UpdateShippingItem(SelectedShippingItem); + } + + private void HandleInvalidSubmit() + { + //FormValidationState = @"Form data is invalid"; + } + + protected void OnItemUpdating(string fieldName, object newValue) + { + BtnSaveEnabled = false; + if (SelectedShippingItem == null) return; + + switch (fieldName) + { + case nameof(ShippingItem.Name): + SelectedShippingItem.Name = newValue.ToString() ?? string.Empty; + break; + case nameof(ShippingItem.GrossWeight): + SelectedShippingItem.GrossWeight = (double)newValue; + break; + case nameof(ShippingItem.NetWeight): + SelectedShippingItem.NetWeight = (double)newValue; + break; + case nameof(ShippingItem.MeasuredGrossWeight): + SelectedShippingItem.MeasuredGrossWeight = (double)newValue; + break; + case nameof(ShippingItem.MeasuredNetWeight): + SelectedShippingItem.MeasuredNetWeight = (double)newValue; + break; + } + + //if (SelectedShippingItem.MeasuredGrossWeight > 0 && SelectedShippingItem.MeasuredNetWeight > 0) + BtnSaveEnabled = true; + } + private async Task GetPartner() { var measuringModel = new MeasuringModel(); diff --git a/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj b/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj index 289c798..6cfc12e 100644 --- a/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj +++ b/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/FruitBankHybrid.Web.Client/Program.cs b/FruitBankHybrid.Web.Client/Program.cs index 7902e57..8e6ab37 100644 --- a/FruitBankHybrid.Web.Client/Program.cs +++ b/FruitBankHybrid.Web.Client/Program.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting; var builder = WebAssemblyHostBuilder.CreateDefault(args); -builder.Services.AddDevExpressBlazor(); +builder.Services.AddDevExpressBlazor(configure => configure.SizeMode = DevExpress.Blazor.SizeMode.Large); // Add device-specific services used by the FruitBankHybrid.Shared project builder.Services.AddSingleton(); diff --git a/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj b/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj index dda9699..f3c9748 100644 --- a/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj +++ b/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj @@ -17,9 +17,9 @@ - - - + + + diff --git a/FruitBankHybrid.Web/Program.cs b/FruitBankHybrid.Web/Program.cs index e746452..8405b86 100644 --- a/FruitBankHybrid.Web/Program.cs +++ b/FruitBankHybrid.Web/Program.cs @@ -9,7 +9,7 @@ using FruitBankHybrid.Web.Services; var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorComponents().AddInteractiveServerComponents().AddInteractiveWebAssemblyComponents(); -builder.Services.AddDevExpressBlazor(); +builder.Services.AddDevExpressBlazor(configure => configure.SizeMode = DevExpress.Blazor.SizeMode.Large); builder.Services.AddMvc(); builder.Services.AddSingleton(); diff --git a/FruitBankHybrid/FruitBankHybrid.csproj b/FruitBankHybrid/FruitBankHybrid.csproj index 29156b2..9964a36 100644 --- a/FruitBankHybrid/FruitBankHybrid.csproj +++ b/FruitBankHybrid/FruitBankHybrid.csproj @@ -63,9 +63,9 @@ - - - + + + diff --git a/FruitBankHybrid/MauiProgram.cs b/FruitBankHybrid/MauiProgram.cs index 049506a..04299fb 100644 --- a/FruitBankHybrid/MauiProgram.cs +++ b/FruitBankHybrid/MauiProgram.cs @@ -39,7 +39,7 @@ namespace FruitBankHybrid builder.Services.AddMauiBlazorWebView(); - builder.Services.AddDevExpressBlazor(); + builder.Services.AddDevExpressBlazor(configure => configure.SizeMode = DevExpress.Blazor.SizeMode.Large); #if DEBUG builder.Services.AddBlazorWebViewDeveloperTools();