improvement, fixes, etc...

This commit is contained in:
Loretta 2025-09-12 13:34:45 +02:00
parent cf234681af
commit 1c666c7ac7
10 changed files with 73 additions and 25 deletions

View File

@ -13,8 +13,8 @@ public class Shipping : MgEntityBase, IShipping
public string LicencePlate { get; set; }
public bool IsAllMeasured { get; set; }
//[Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(ShippingItem.sh))]
//public IEnumerable<Shipping> Shippings { get; set; }
[Association(ThisKey = nameof(Id), OtherKey = nameof(ShippingDocument.ShippingId))]
public List<ShippingDocument>? ShippingDocuments { get; set; }
[SkipValuesOnUpdate]

View File

@ -10,10 +10,16 @@ public class ShippingDocument : MgEntityBase, IShippingDocument
{
public int PartnerId { get; set; }
public int ShippingId { get; set; }
public int ShippingItemId { get; set; }
public DateTime ShippingDate { get; set; }
public string Country { get; set; }
[Association(ThisKey = nameof(PartnerId), OtherKey = nameof(Partner.Id))]
public Partner? Partner { get; set; }
[Association(ThisKey = nameof(Id), OtherKey = nameof(ShippingItem.ShippingDocumentId))]
public List<ShippingItem>? ShippingItems { get; set; }
[SkipValuesOnUpdate]
public DateTime Created { get; set; }
public DateTime Modified { get; set; }

View File

@ -11,7 +11,7 @@ namespace FruitBank.Common.Entities;
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingItemDbTableName)]
public class ShippingItem : MgEntityBase, IShippingItem
{
public int ProductId { get; set; }
public int? ProductId { get; set; }
//[Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(Shipping.Id))]
//public IEnumerable<Shipping> Shippings { get; set; }
@ -19,8 +19,8 @@ public class ShippingItem : MgEntityBase, IShippingItem
public string Name { get; set; }
public double NetWeight { get; set; }
public double GrossWeight { get; set; }
public double MeasuredNetWeight { get; set; }
public double MeasuredGrossWeight { get; set; }
public double? MeasuredNetWeight { get; set; }
public double? MeasuredGrossWeight { get; set; }
public bool IsMeasured { get; set; }
[SkipValuesOnUpdate]

View File

@ -18,17 +18,21 @@ public interface IFruitBankDataControllerCommon
#region Shipping
public Task<List<Shipping>?> GetShippings();
Task<List<Shipping>?> GetNotMeasuredShippings();
public Task<Shipping?> GetShippingById(int id);
public Task<Shipping?> UpdateShipping(Shipping shipping);
#endregion Shipping
#region ShippingItem
public Task<List<ShippingItem>?> GetShippingItems();
public Task<ShippingItem?> GetShippingItemById(int id);
public Task<ShippingItem?> UpdateShippingItem(ShippingItem shippingItem);
#endregion ShippingItem
#region ShippingDocument
public Task<List<ShippingDocument>?> GetShippingDocuments();
public Task<ShippingDocument?> GetShippingDocumentById(int id);
public Task<ShippingDocument?> UpdateShippingDocument(ShippingDocument shippingDocument);
#endregion ShippingDocument
#region Customer

View File

@ -1,5 +1,6 @@
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;
using FruitBank.Common.Entities;
namespace FruitBank.Common.Interfaces;
@ -9,4 +10,6 @@ public interface IShipping : IEntityInt, ITimeStampInfo
DateTime ShippingDate { get; set; }
string LicencePlate { get; set; }
bool IsAllMeasured { get; set; }
public List<ShippingDocument>? ShippingDocuments { get; set; }
}

View File

@ -1,5 +1,6 @@
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;
using FruitBank.Common.Entities;
namespace FruitBank.Common.Interfaces;
@ -7,7 +8,9 @@ public interface IShippingDocument: IEntityInt, ITimeStampInfo
{
public int PartnerId { get; set; }
public int ShippingId { get; set; }
public int ShippingItemId { get; set; }
public DateTime ShippingDate { get; set; }
public string Country { get; set; }
public Partner? Partner { get; set; }
public List<ShippingItem>? ShippingItems { get; set; }
}

View File

@ -6,13 +6,13 @@ namespace FruitBank.Common.Interfaces;
public interface IShippingItem : IEntityInt, ITimeStampInfo
{
int ShippingDocumentId { get; set; }
int ProductId { get; set; }
int? ProductId { get; set; }
string Name { get; set; }
double NetWeight { get; set; }
double GrossWeight { get; set; }
double MeasuredNetWeight { get; set; }
double MeasuredGrossWeight { get; set; }
double? MeasuredNetWeight { get; set; }
double? MeasuredGrossWeight { get; set; }
bool IsMeasured { get; set; }
}

View File

@ -11,16 +11,24 @@ public class SignalRTags : AcSignalRTags
public const int GetPartners = 20;
public const int GetPartnerById = 21;
public const int UpdatePartner = 25;
public const int AddPartner = 25;
public const int UpdatePartner = 26;
public const int GetShippings = 40;
public const int GetShippingById = 41;
public const int GetNotMeasuredShippings = 41;
public const int GetShippingById = 42;
public const int AddShipping = 45;
public const int UpdateShipping = 46;
public const int GetShippingItems = 50;
public const int GetShippingItemById = 51;
public const int AddShippingItem = 55;
public const int UpdateShippingItem = 56;
public const int GetShippingDocuments = 60;
public const int GetShippingDocumentById = 61;
public const int AddShippingDocument = 65;
public const int UpdateShippingDocument = 66;
public const int GetMeasuringUsers = 70;
public const int GetCustomerDtoById = 71;

View File

@ -1,11 +1,9 @@
using AyCode.Core.Enums;
using AyCode.Core.Extensions;
using AyCode.Core.Loggers;
using AyCode.Utils.Extensions;
using FruitBank.Common.Entities;
using FruitBank.Common.Loggers;
using FruitBankHybrid.Shared.Services.SignalRs;
using Mango.Nop.Core.Dtos;
namespace FruitBankHybrid.Shared.Tests
{
@ -76,16 +74,30 @@ namespace FruitBankHybrid.Shared.Tests
var shippings = await _signalRClient.GetShippings();
Assert.IsNotNull(shippings);
Assert.IsTrue(shippings.Any());
Assert.IsTrue(shippings.Count != 0);
}
[TestMethod]
public async Task GetShippingByIdTest()
public async Task GetNotMeasuredShippingsTest()
{
var shipping = await _signalRClient.GetShippingById(1);
var shippings = await _signalRClient.GetNotMeasuredShippings();
Assert.IsNotNull(shippings);
Assert.IsTrue(shippings.All(s => !s.IsAllMeasured));
}
[TestMethod]
[DataRow(1)]
public async Task GetShippingByIdTest(int shippingId)
{
var shipping = await _signalRClient.GetShippingById(shippingId);
Assert.IsNotNull(shipping);
Assert.IsTrue(shipping.Id == 1);
Assert.IsNotNull(shipping.ShippingDocuments);
Assert.IsTrue(shipping.Id == shippingId);
Assert.IsTrue(shipping.ShippingDocuments.All(s => s.ShippingId == shippingId));
Assert.IsTrue(shipping.ShippingDocuments.All(sd => sd.ShippingItems != null && sd.ShippingItems.Any(si => si.ShippingDocumentId == sd.Id)));
}
#endregion Shipping
@ -102,12 +114,13 @@ namespace FruitBankHybrid.Shared.Tests
}
[TestMethod]
public async Task GetShippingItemByIdTest()
[DataRow(1)]
public async Task GetShippingItemByIdTest(int shippingItemeId)
{
var shippingItem = await _signalRClient.GetShippingItemById(1);
var shippingItem = await _signalRClient.GetShippingItemById(shippingItemeId);
Assert.IsNotNull(shippingItem);
Assert.IsTrue(shippingItem.Id == 1);
Assert.IsTrue(shippingItem.Id == shippingItemeId);
}
#endregion ShippingItem
@ -124,12 +137,13 @@ namespace FruitBankHybrid.Shared.Tests
}
[TestMethod]
public async Task GetShippingDocumentByIdTest()
[DataRow(2)]
public async Task GetShippingDocumentByIdTest(int shippingDocumentId)
{
var shippingDocument = await _signalRClient.GetShippingDocumentById(1);
var shippingDocument = await _signalRClient.GetShippingDocumentById(shippingDocumentId);
Assert.IsNotNull(shippingDocument);
Assert.IsTrue(shippingDocument.Id == 1);
Assert.IsTrue(shippingDocument.Id == shippingDocumentId);
}
#endregion ShippingDocument

View File

@ -42,7 +42,7 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
=> GetByIdAsync<Partner?>(SignalRTags.GetPartnerById, id);
public Task<Partner?> UpdatePartner(Partner partner)
=> PostDataAsync<Partner>(SignalRTags.UpdatePartner, partner);
=> PostDataAsync(SignalRTags.UpdatePartner, partner);
#endregion Partner
@ -51,9 +51,15 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
public Task<List<Shipping>?> GetShippings()
=> GetAllAsync<List<Shipping>>(SignalRTags.GetShippings);
public Task<List<Shipping>?> GetNotMeasuredShippings()
=> GetAllAsync<List<Shipping>>(SignalRTags.GetNotMeasuredShippings);
public Task<Shipping?> GetShippingById(int id)
=> GetByIdAsync<Shipping?>(SignalRTags.GetShippingById, id);
public Task<Shipping?> UpdateShipping(Shipping shipping)
=> PostDataAsync(SignalRTags.UpdateShipping, shipping);
#endregion Shipping
#region ShippingItem
@ -64,6 +70,8 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
public Task<ShippingItem?> GetShippingItemById(int id)
=> GetByIdAsync<ShippingItem?>(SignalRTags.GetShippingItemById, id);
public Task<ShippingItem?> UpdateShippingItem(ShippingItem shippingItem)
=> PostDataAsync(SignalRTags.UpdateShippingItem, shippingItem);
#endregion ShippingItem
#region ShippingDocument
@ -74,6 +82,8 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
public Task<ShippingDocument?> GetShippingDocumentById(int id)
=> GetByIdAsync<ShippingDocument?>(SignalRTags.GetShippingDocumentById, id);
public Task<ShippingDocument?> UpdateShippingDocument(ShippingDocument shippingDocument)
=> PostDataAsync(SignalRTags.UpdateShippingDocument, shippingDocument);
#endregion ShippingDocument
#region Customer