improvements, fixes, etc...
This commit is contained in:
parent
0c2c5ab8ee
commit
d7e58e28f5
|
|
@ -0,0 +1,45 @@
|
|||
using FruitBank.Common.Interfaces;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
|
||||
namespace FruitBank.Common.Dtos;
|
||||
|
||||
public class MeasuringProductDto : ProductDto, IMeasuringProductDto
|
||||
{
|
||||
public double? NetWeight { get; set; }
|
||||
public double? GrossWeight { get; set; }
|
||||
public bool? IsMeasurable { get; set; }
|
||||
|
||||
public MeasuringProductDto() :base()
|
||||
{ }
|
||||
public MeasuringProductDto(int productId) : base(productId)
|
||||
{ }
|
||||
public MeasuringProductDto(Product product, IMeasuringAttributeValues? measuringAttributeValues)
|
||||
{
|
||||
CopyEntityValuesToDto(product, measuringAttributeValues);
|
||||
}
|
||||
|
||||
public void CopyDtoValuesToEntity(Product entity, IMeasuringAttributeValues measuringAttributeValues)
|
||||
{
|
||||
base.CopyDtoValuesToEntity(entity);
|
||||
|
||||
measuringAttributeValues.Id = Id;
|
||||
measuringAttributeValues.NetWeight = NetWeight;
|
||||
measuringAttributeValues.GrossWeight = GrossWeight;
|
||||
measuringAttributeValues.IsMeasurable = IsMeasurable;
|
||||
}
|
||||
|
||||
public void CopyEntityValuesToDto(Product entity, IMeasuringAttributeValues? measuringAttributeValues)
|
||||
{
|
||||
if (measuringAttributeValues != null && entity.Id != measuringAttributeValues.Id)
|
||||
throw new Exception($"MeasuringProductDto->CopyEntityValuesToDto(Product entity, IMeasuringAttributeValues measuringAttributeValues); entity.Id != measuringAttributeValues.Id; entityId: {entity.Id}; measuringAttributeValues.Id: {measuringAttributeValues.Id}");
|
||||
|
||||
base.CopyEntityValuesToDto(entity);
|
||||
|
||||
NetWeight = measuringAttributeValues?.NetWeight;
|
||||
GrossWeight = measuringAttributeValues?.GrossWeight;
|
||||
IsMeasurable = measuringAttributeValues?.IsMeasurable;
|
||||
}
|
||||
|
||||
public bool HasValues() => Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
||||
}
|
||||
|
|
@ -43,8 +43,4 @@
|
|||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dtos\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Models;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Mango.Nop.Core.Models;
|
||||
|
|
@ -44,6 +45,9 @@ public interface IFruitBankDataControllerCommon
|
|||
|
||||
#region Product
|
||||
public Task<List<ProductDto>?> GetProductDtos();
|
||||
public Task<List<MeasuringProductDto>?> GetAllMeasuringProductDtos();
|
||||
public Task<MeasuringProductDto?> GetMeasuringProductDtoById(int productId);
|
||||
|
||||
#endregion Product
|
||||
|
||||
Task<MgLoginModelResponse?> LoginMeasuringUser(MgLoginModelRequest loginModelRequest);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
namespace FruitBank.Common.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
|
||||
public interface IMeasuringAttributeValues
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IMeasuringAttributeValues : IEntityInt
|
||||
{
|
||||
double? NetWeight { get; set; }
|
||||
double? GrossWeight { get; set; }
|
||||
|
||||
bool? IsMeasurable { get; set; }
|
||||
|
||||
bool HasValues(); //=> Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using Mango.Nop.Core.Interfaces;
|
||||
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IMeasuringProductDto : IProductDto, IMeasuringAttributeValues
|
||||
{
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
using System.Runtime;
|
||||
|
||||
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;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"NetWeight: {NetWeight}; GrossWeight: {GrossWeight}; IsMeasurable: {IsMeasurable}";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using FruitBank.Common.Interfaces;
|
||||
using System.Runtime;
|
||||
|
||||
namespace FruitBank.Common.Models;
|
||||
|
||||
public class MeasuringAttributeValues : IMeasuringAttributeValues
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public double? NetWeight { get; set; }
|
||||
public double? GrossWeight { get; set; }
|
||||
public bool? IsMeasurable { get; set; }
|
||||
|
||||
public MeasuringAttributeValues()
|
||||
{
|
||||
}
|
||||
|
||||
public MeasuringAttributeValues(int entityId, double? netWeight, double? grossWeight, bool? isMeasurable)
|
||||
{
|
||||
Initialize(entityId, netWeight, grossWeight, isMeasurable);
|
||||
}
|
||||
|
||||
public void Initialize(int entityId, double? netWeight, double? grossWeight, bool? isMeasurable)
|
||||
{
|
||||
Id = entityId;
|
||||
NetWeight = netWeight;
|
||||
GrossWeight = grossWeight;
|
||||
IsMeasurable = isMeasurable;
|
||||
}
|
||||
|
||||
public bool HasValues() => Id > 0 && NetWeight != null && GrossWeight != null && IsMeasurable != null;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"EntityId: {Id}; NetWeight: {NetWeight}; GrossWeight: {GrossWeight}; IsMeasurable: {IsMeasurable}";
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,9 @@ public class SignalRTags : AcSignalRTags
|
|||
|
||||
public const int GetProductDtos = 80;
|
||||
public const int GetProductDtoById = 81;
|
||||
public const int GetAllMeasuringProductDtos = 82;
|
||||
public const int GetMeasuringProductDtoById = 83;
|
||||
|
||||
|
||||
public const int AuthenticateUser = 160;
|
||||
public const int RefreshToken = 200;
|
||||
|
|
|
|||
|
|
@ -280,6 +280,31 @@ namespace FruitBankHybrid.Shared.Tests
|
|||
Assert.IsTrue(productDto.All(x => !x.Name.IsNullOrEmpty() && !x.Deleted));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task GetAllMeasuringProductDtosTest()
|
||||
{
|
||||
var measuringProductDtos = await _signalRClient.GetAllMeasuringProductDtos();
|
||||
|
||||
Assert.IsNotNull(measuringProductDtos);
|
||||
Assert.IsTrue(measuringProductDtos.Count != 0);
|
||||
|
||||
Assert.IsTrue(measuringProductDtos.All(x => !x.Name.IsNullOrEmpty() && !x.Deleted));
|
||||
Assert.IsTrue(measuringProductDtos.All(x => !x.IsMeasurable.GetValueOrDefault(false) || x.HasValues()));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(5)]
|
||||
[DataRow(33)]
|
||||
//[DataRow(3)]
|
||||
public async Task GetMeasuringProductDtoByIdTest(int productId)
|
||||
{
|
||||
var measuringProductDto = await _signalRClient.GetMeasuringProductDtoById(productId);
|
||||
|
||||
Assert.IsNotNull(measuringProductDto);
|
||||
Assert.IsTrue(measuringProductDto.HasValues());
|
||||
//Assert.IsTrue(measuringProductDto.HasValues());
|
||||
}
|
||||
#endregion Product
|
||||
|
||||
#region Login
|
||||
|
|
|
|||
|
|
@ -10,8 +10,13 @@
|
|||
<div class="top-row px-4">
|
||||
@if (LoggedInModel.IsLoggedIn)
|
||||
{
|
||||
<DxButton Text="Kijelentkezés" Click="OnLogoutClick" />
|
||||
@* <a href="" on>Kijelentkezés</a> *@
|
||||
<div style="float: left; text-align: left;" class="col-md-8">
|
||||
<b>@($"{LoggedInModel.CustomerDto!.FullName} [{string.Join(", ", LoggedInModel.CustomerRoles.Where(x=>x.SystemName.Contains("Measuring")).Select(x => x.Name))}]")</b>
|
||||
</div>
|
||||
|
||||
<div style="float: right; text-align: right;" class="col-md-4">
|
||||
<DxButton Text="Kijelentkezés" Click="OnLogoutClick" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -109,23 +109,19 @@
|
|||
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
|
||||
Field="@nameof(ShippingItem.MeasuredQuantity)"
|
||||
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
||||
Caption="MeasuredQuantity:"
|
||||
ColSpanMd="2"
|
||||
BeginRow="false">
|
||||
Caption="MeasuredQuantity:" ColSpanMd="2" BeginRow="false">
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
|
||||
Field="@nameof(ShippingItem.MeasuredGrossWeight)"
|
||||
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
||||
Caption="MeasuredGrossWeight:"
|
||||
ColSpanMd="2">
|
||||
Caption="MeasuredGrossWeight:" ColSpanMd="2">
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
|
||||
Field="@nameof(ShippingItem.MeasuredNetWeight)"
|
||||
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
|
||||
Caption="MeasuredNetWeight:"
|
||||
ColSpanMd="2">
|
||||
Caption="MeasuredNetWeight:" ColSpanMd="2">
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
|
||||
|
|
@ -145,10 +141,17 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
|
||||
<text>Nem végezhető el a mérés, nincs megadva a ProductId! Jelezze a vezetőségnek...</text>
|
||||
</DxFormLayoutItem>
|
||||
_errorText = "Nem végezhető el a mérés, nincs megadva a ProductId! Jelezze a vezetőségnek...";
|
||||
}
|
||||
|
||||
@if (!_errorText.IsNullOrWhiteSpace())
|
||||
{
|
||||
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
|
||||
<text>HIBA! @_errorText</text>
|
||||
</DxFormLayoutItem>
|
||||
//_errorText = string.Empty;
|
||||
}
|
||||
|
||||
</DxFormLayout>
|
||||
</EditForm>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
using AyCode.Core.Loggers;
|
||||
using DevExpress.Blazor;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Models;
|
||||
using FruitBankHybrid.Shared.Services.Loggers;
|
||||
using FruitBankHybrid.Shared.Services.SignalRs;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using ILogger = Mango.Nop.Core.Loggers.ILogger;
|
||||
|
||||
namespace FruitBankHybrid.Shared.Pages
|
||||
|
|
@ -29,6 +31,7 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
[Inject] public required LoggedInModel LoggedInModel { get; set; }
|
||||
|
||||
private ILogger _logger = null!;
|
||||
private string _errorText;
|
||||
|
||||
private List<Shipping> NotMeasuredShippings { get; set; } = null!;
|
||||
private Shipping? SelectedShipping { get; set; }
|
||||
|
|
@ -40,10 +43,6 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
|
||||
private List<ShippingDateModel> _shippingDates = null!;
|
||||
|
||||
private string _userName = "Partner name";
|
||||
private string _message = string.Empty;
|
||||
private readonly List<(string User, string Text)> _messages = [];
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<MeasuringIn>(LogWriters.ToArray());
|
||||
|
|
@ -155,9 +154,7 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
var updatedShippingItem = await FruitBankSignalRClient.UpdateMeasuredShippingItem(shippingItem);
|
||||
if (updatedShippingItem == null)
|
||||
{
|
||||
_logger.Error($"Sikertelen volt a shippingItem mentése! Id: {shippingItem.Id}");
|
||||
//TODO: - J.
|
||||
|
||||
LogErrorAndDisplayText($"Sikertelen volt a shippingItem mentése! Id: {shippingItem.Id}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -202,24 +199,19 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
break;
|
||||
}
|
||||
|
||||
if (SelectedShippingItem.IsValidMeasuringValues())
|
||||
BtnSaveEnabled = true;
|
||||
BtnSaveEnabled = SelectedShippingItem.IsValidMeasuringValues();
|
||||
}
|
||||
|
||||
private async Task GetPartner()
|
||||
private void LogErrorAndDisplayText(string errorText, Exception? ex = null)
|
||||
{
|
||||
var measuringModel = new MeasuringModel();
|
||||
_errorText = errorText;
|
||||
_logger.Error($"{errorText}", ex);
|
||||
//Nem végezhető el a mérés, nincs megadva a ProductId! Jelezze a vezetőségnek...
|
||||
}
|
||||
|
||||
if (int.TryParse(_message, out var partnerId))
|
||||
{
|
||||
_message = string.Empty;
|
||||
|
||||
measuringModel.Name = (await FruitBankSignalRClient.GetPartnerById(partnerId))?.Name!;
|
||||
//measuringModel.Name = (await FruitBankSignalRClient.GetMeasuringModelByShippingId(partnerId))?.Name!;
|
||||
}
|
||||
|
||||
_messages.Add((_userName, measuringModel?.Name ?? "ERROR"));
|
||||
//StateHasChanged();
|
||||
protected void OnAnyMeasuringValueKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
BtnSaveEnabled = SelectedShippingItem?.IsValidMeasuringValues() ?? false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using AyCode.Core.Loggers;
|
|||
using AyCode.Services.Server.SignalRs;
|
||||
using AyCode.Services.SignalRs;
|
||||
using FruitBank.Common;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Models;
|
||||
|
|
@ -104,6 +105,13 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
|
|||
|
||||
public Task<List<ProductDto>?> GetProductDtos()
|
||||
=> GetAllAsync<List<ProductDto>>(SignalRTags.GetProductDtos);
|
||||
|
||||
public Task<List<MeasuringProductDto>?> GetAllMeasuringProductDtos()
|
||||
=> GetAllAsync<List<MeasuringProductDto>>(SignalRTags.GetAllMeasuringProductDtos);
|
||||
|
||||
public Task<MeasuringProductDto?> GetMeasuringProductDtoById(int productId)
|
||||
=> GetByIdAsync<MeasuringProductDto?>(SignalRTags.GetMeasuringProductDtoById, productId);
|
||||
|
||||
#endregion Product
|
||||
|
||||
#region Authenticate
|
||||
|
|
|
|||
Loading…
Reference in New Issue