From df4715360ee0cc07a333bdcf3c95f98cff4ad951 Mon Sep 17 00:00:00 2001 From: Loretta Date: Mon, 29 Sep 2025 13:33:34 +0200 Subject: [PATCH] improvements, fixes, etc... --- FruitBank.Common.Server/FruitBankConst.cs | 3 + FruitBank.Common/Entities/Shipping.cs | 2 + .../IFruitBankDataControllerCommon.cs | 2 + .../Interfaces/IMeasuringAttributeValues.cs | 9 +++ FruitBank.Common/Interfaces/IShipping.cs | 1 + .../Interfaces/MeasuringAttributeValues.cs | 27 +++++++ FruitBank.Common/Models/LoggedInModel.cs | 46 ++++++++++++ FruitBank.Common/SignalRs/SignalRTags.cs | 1 + .../FruitBankClientTests.cs | 23 +++++- .../FruitBankHybrid.Shared.csproj | 12 ++-- .../Layout/MainLayout.razor | 37 ++++++---- .../Layout/MainLayout.razor.cs | 25 +++++++ FruitBankHybrid.Shared/Layout/NavMenu.razor | 47 +++++++----- .../Layout/NavMenu.razor.bak | 30 -------- FruitBankHybrid.Shared/Pages/Home.razor.cs | 5 +- FruitBankHybrid.Shared/Pages/Login.razor | 72 ++++++++++--------- FruitBankHybrid.Shared/Pages/Login.razor.cs | 35 ++++++++- .../Pages/MeasuringIn.razor | 8 +-- .../Pages/MeasuringIn.razor.cs | 7 +- .../Pages/MeasuringOut.razor.cs | 4 +- .../SignalRs/FruitBankSignalRClient.cs | 5 +- .../FruitBankHybrid.Web.Client.csproj | 10 +-- FruitBankHybrid.Web.Client/Program.cs | 2 + .../FruitBankHybrid.Web.csproj | 12 ++-- FruitBankHybrid.Web/Program.cs | 6 +- FruitBankHybrid/MauiProgram.cs | 25 ++++--- 26 files changed, 315 insertions(+), 141 deletions(-) create mode 100644 FruitBank.Common/Interfaces/IMeasuringAttributeValues.cs create mode 100644 FruitBank.Common/Interfaces/MeasuringAttributeValues.cs create mode 100644 FruitBank.Common/Models/LoggedInModel.cs create mode 100644 FruitBankHybrid.Shared/Layout/MainLayout.razor.cs delete mode 100644 FruitBankHybrid.Shared/Layout/NavMenu.razor.bak diff --git a/FruitBank.Common.Server/FruitBankConst.cs b/FruitBank.Common.Server/FruitBankConst.cs index 284a463..3236365 100644 --- a/FruitBank.Common.Server/FruitBankConst.cs +++ b/FruitBank.Common.Server/FruitBankConst.cs @@ -10,7 +10,10 @@ namespace FruitBank.Common.Server public class FruitBankConst : AcConst { public static string ProjectIdString = "aad53443-2ee2-4650-8a99-97e907265e4e"; + public static string MeasuringRoleSystemName = "Measuring"; + public static string MeasuringRevisorRoleSystemName = "MeasuringRevisor"; + public static string IsMeasureableAttributeName = "IsMeasurable"; static FruitBankConst() { diff --git a/FruitBank.Common/Entities/Shipping.cs b/FruitBank.Common/Entities/Shipping.cs index 2e888fd..4458883 100644 --- a/FruitBank.Common/Entities/Shipping.cs +++ b/FruitBank.Common/Entities/Shipping.cs @@ -13,6 +13,8 @@ public class Shipping : MgEntityBase, IShipping public string LicencePlate { get; set; } public bool IsAllMeasured { get; set; } + public DateTime? MeasuredDate { get; set; } + [Association(ThisKey = nameof(Id), OtherKey = nameof(ShippingDocument.ShippingId), CanBeNull = true)] public List? ShippingDocuments { get; set; } diff --git a/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs b/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs index 64bcff5..d274b88 100644 --- a/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs +++ b/FruitBank.Common/Interfaces/IFruitBankDataControllerCommon.cs @@ -2,6 +2,7 @@ using FruitBank.Common.Models; using Mango.Nop.Core.Dtos; using Mango.Nop.Core.Models; +using Nop.Core.Domain.Customers; namespace FruitBank.Common.Interfaces; @@ -38,6 +39,7 @@ public interface IFruitBankDataControllerCommon #region Customer public Task?> GetMeasuringUsers(); + public Task?> GetCustomerRolesByCustomerId(int customerId); #endregion Customer #region Product diff --git a/FruitBank.Common/Interfaces/IMeasuringAttributeValues.cs b/FruitBank.Common/Interfaces/IMeasuringAttributeValues.cs new file mode 100644 index 0000000..07dd864 --- /dev/null +++ b/FruitBank.Common/Interfaces/IMeasuringAttributeValues.cs @@ -0,0 +1,9 @@ +namespace FruitBank.Common.Interfaces; + +public interface IMeasuringAttributeValues +{ + double? NetWeight { get; set; } + double? GrossWeight { get; set; } + + bool? IsMeasurable { get; set; } +} \ No newline at end of file diff --git a/FruitBank.Common/Interfaces/IShipping.cs b/FruitBank.Common/Interfaces/IShipping.cs index dd64664..0e9ed03 100644 --- a/FruitBank.Common/Interfaces/IShipping.cs +++ b/FruitBank.Common/Interfaces/IShipping.cs @@ -10,6 +10,7 @@ public interface IShipping : IEntityInt, ITimeStampInfo DateTime ShippingDate { get; set; } string LicencePlate { get; set; } bool IsAllMeasured { get; set; } + DateTime? MeasuredDate { get; set; } public List? ShippingDocuments { get; set; } } \ No newline at end of file diff --git a/FruitBank.Common/Interfaces/MeasuringAttributeValues.cs b/FruitBank.Common/Interfaces/MeasuringAttributeValues.cs new file mode 100644 index 0000000..36ca6ac --- /dev/null +++ b/FruitBank.Common/Interfaces/MeasuringAttributeValues.cs @@ -0,0 +1,27 @@ +namespace FruitBank.Common.Interfaces; + +public class MeasuringAttributeValues : IMeasuringAttributeValues +{ + public double? NetWeight { get; set; } + public double? GrossWeight { get; set; } + public bool? IsMeasurable { get; set; } + + public MeasuringAttributeValues() + { + } + + public MeasuringAttributeValues(double? netWeight, double? grossWeight, bool? isMeasurable) + { + Initialize(netWeight, grossWeight, isMeasurable); + } + + public void Initialize(double? netWeight, double? grossWeight, bool? isMeasurable) + { + NetWeight = netWeight; + GrossWeight = grossWeight; + IsMeasurable = isMeasurable; + } + + public bool HasValues() + => NetWeight != null && GrossWeight != null && IsMeasurable != null; +} \ No newline at end of file diff --git a/FruitBank.Common/Models/LoggedInModel.cs b/FruitBank.Common/Models/LoggedInModel.cs new file mode 100644 index 0000000..1b7cb00 --- /dev/null +++ b/FruitBank.Common/Models/LoggedInModel.cs @@ -0,0 +1,46 @@ +using AyCode.Core; +using Mango.Nop.Core.Dtos; +using Mango.Nop.Core.Models; +using Nop.Core.Domain.Customers; + +namespace FruitBank.Common.Models; + +public class LoggedInModel +{ + public bool IsLoggedIn => CustomerDto != null; + + public CustomerDto? CustomerDto { get; private set; } + public List CustomerRoles { get; private set; } = []; + + public LoggedInModel() + { + } + + public LoggedInModel(CustomerDto? customerDto) + { + InitLoggedInCustomer(customerDto); + } + + public LoggedInModel(MgLoginModelResponse loginModelResponse) : this(loginModelResponse.CustomerDto) + { + } + + public void InitLoggedInCustomer(CustomerDto? customerDto) + { + LogOut(); + + if (customerDto != null) CustomerDto = customerDto; + } + + public void InitCustomerRoles(List customerRoles) + { + CustomerRoles.Clear(); + CustomerRoles.AddRange(customerRoles); + } + + public void LogOut() + { + CustomerDto = null; + CustomerRoles.Clear(); + } +} \ No newline at end of file diff --git a/FruitBank.Common/SignalRs/SignalRTags.cs b/FruitBank.Common/SignalRs/SignalRTags.cs index 6917a43..dd2894f 100644 --- a/FruitBank.Common/SignalRs/SignalRTags.cs +++ b/FruitBank.Common/SignalRs/SignalRTags.cs @@ -33,6 +33,7 @@ public class SignalRTags : AcSignalRTags public const int GetMeasuringUsers = 70; public const int GetCustomerDtoById = 71; + public const int GetCustomerRolesByCustomerId = 72; public const int GetProductDtos = 80; public const int GetProductDtoById = 81; diff --git a/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs b/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs index 834572a..3b1c742 100644 --- a/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs +++ b/FruitBankHybrid.Shared.Tests/FruitBankClientTests.cs @@ -6,12 +6,15 @@ using FruitBank.Common.Interfaces; using FruitBank.Common.Loggers; using FruitBankHybrid.Shared.Services.SignalRs; using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices.JavaScript; +using FruitBank.Common; namespace FruitBankHybrid.Shared.Tests { [TestClass] public sealed class FruitBankClientTests { + private const int CustomerIdAasdDsserverCom = 6;//aasd@dsserver.com private const string Fixture = "_test.temp"; private FruitBankSignalRClient _signalRClient = null!; @@ -88,7 +91,8 @@ namespace FruitBankHybrid.Shared.Tests var shippings = await _signalRClient.GetNotMeasuredShippings(); Assert.IsNotNull(shippings); - Assert.IsTrue(shippings.All(s => !s.IsAllMeasured)); + var ShippingMeasuredDateAddDay = 1000; //dfd + Assert.IsTrue(shippings.All(s => !s.IsAllMeasured || s.MeasuredDate != null || s.MeasuredDate < DateTime.Now.AddDays(ShippingMeasuredDateAddDay))); } //[TestMethod] @@ -159,7 +163,9 @@ namespace FruitBankHybrid.Shared.Tests [DataTestMethod] [DataRow(1)] - //[DataRow(2)] + [DataRow(2)] + //[DataRow(3)] + //[DataRow(4)] public async Task UpdateShippingItemTest(int shippingItemId) { var originalShippingItem = await GetShippingItemByIdTest(shippingItemId); @@ -249,6 +255,17 @@ namespace FruitBankHybrid.Shared.Tests Assert.IsTrue(users.All(x => !x.Email.IsNullOrEmpty() && !x.Deleted)); } + [TestMethod] + [DataRow(CustomerIdAasdDsserverCom)] + public async Task GetCustomerRolesByCustomerIdTest(int customerId) + { + var customerRoles = await _signalRClient.GetCustomerRolesByCustomerId(customerId); + + Assert.IsNotNull(customerRoles); + Assert.IsTrue(customerRoles.Count > 0); + Assert.IsTrue(customerRoles.Any(cr => cr.SystemName == "Measuring")); + } + #endregion Customer #region Product @@ -265,6 +282,7 @@ namespace FruitBankHybrid.Shared.Tests #endregion Product + #region Login [TestMethod] [DataRow("aasd@dsserver.com", "Asdasd123456")] public async Task LoginMeasuringUserTest_TrueIfHasCustomerDto(string email, string password) @@ -289,5 +307,6 @@ namespace FruitBankHybrid.Shared.Tests Assert.IsFalse(loginModelResponse.ErrorMessage.IsNullOrWhiteSpace()); Console.WriteLine($"Succes: {loginModelResponse.ErrorMessage}"); } + #endregion Login } } diff --git a/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj b/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj index 5025ca6..96ba4eb 100644 --- a/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj +++ b/FruitBankHybrid.Shared/FruitBankHybrid.Shared.csproj @@ -11,7 +11,7 @@ - + @@ -46,19 +46,19 @@ ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll - C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.Resources.v25.1.dll + - C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.dll + - C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Blazor.v25.1.Viewer.dll + - C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Data.v25.1.dll + - C:\Program Files\DevExpress 25.1\Components\Bin\NetCore\DevExpress.Utils.v25.1.dll + ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll diff --git a/FruitBankHybrid.Shared/Layout/MainLayout.razor b/FruitBankHybrid.Shared/Layout/MainLayout.razor index a9ea6a6..b602d09 100644 --- a/FruitBankHybrid.Shared/Layout/MainLayout.razor +++ b/FruitBankHybrid.Shared/Layout/MainLayout.razor @@ -1,23 +1,30 @@ -@inherits LayoutComponentBase +@using FruitBank.Common.Models +@inherits LayoutComponentBase
- + -
- +
+
+ @if (LoggedInModel.IsLoggedIn) + { + + @* Kijelentkezés *@ + } +
-
- @Body -
-
+
+ + @Body + +
+
- An unhandled error has occurred. - Reload - 🗙 + An unhandled error has occurred. + Reload + 🗙
diff --git a/FruitBankHybrid.Shared/Layout/MainLayout.razor.cs b/FruitBankHybrid.Shared/Layout/MainLayout.razor.cs new file mode 100644 index 0000000..da1a724 --- /dev/null +++ b/FruitBankHybrid.Shared/Layout/MainLayout.razor.cs @@ -0,0 +1,25 @@ +using FruitBank.Common.Models; +using Microsoft.AspNetCore.Components; + +namespace FruitBankHybrid.Shared.Layout; + +public partial class MainLayout : LayoutComponentBase +{ + [Inject] public required LoggedInModel LoggedInModel { get; set; } + + private EventCallback RefreshMainLayoutEventCallback => EventCallback.Factory.Create(this, RefreshMainLayout); + private NavMenu _navMenu = null!; + + private void OnLogoutClick() + { + LoggedInModel.LogOut(); + + RefreshMainLayout(); + } + + public void RefreshMainLayout() + { + _navMenu.RefreshNavMenu(); + StateHasChanged(); + } +} \ No newline at end of file diff --git a/FruitBankHybrid.Shared/Layout/NavMenu.razor b/FruitBankHybrid.Shared/Layout/NavMenu.razor index 6c32408..10bdb2d 100644 --- a/FruitBankHybrid.Shared/Layout/NavMenu.razor +++ b/FruitBankHybrid.Shared/Layout/NavMenu.razor @@ -1,4 +1,8 @@ -