FruitBankHybridApp/FruitBank.Common/Entities/ShippingItemPallet.cs

45 lines
1.6 KiB
C#

using System.ComponentModel.DataAnnotations;
using FruitBank.Common.Interfaces;
using LinqToDB.Mapping;
using Mango.Nop.Core.Entities;
using DataType = LinqToDB.DataType;
namespace FruitBank.Common.Entities;
[Table(Name = FruitBankConstClient.ShippingItemPalletDbTableName)]
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingItemPalletDbTableName)]
public class ShippingItemPallet : MgEntityBase, IShippingItemPallet
{
public int ShippingItemId { get; set; }
//[Nullable]
//[Column(CanBeNull = true)]
[Range(1, 100000, ErrorMessage = "The Quantity value should be a number between 1 and 100,000.")]
public int Quantity { get; set; }
//[Nullable]
[Column(DataType = DataType.DecFloat, CanBeNull = false)]
[Range(1, 100000, ErrorMessage = "The NetWeight value should be a number between 1 and 100,000.")]
public double NetWeight { get; set; }
//[Nullable]
[Column(DataType = DataType.DecFloat, CanBeNull = false)]
[Range(1, 100000, ErrorMessage = "The GrossWeight value should be a number between 1 and 100,000.")]
public double GrossWeight { get; set; }
[LinqToDB.Mapping.Association(ThisKey = nameof(ShippingItemId), OtherKey = nameof(ShippingItem.Id), CanBeNull = true)]
public ShippingItem? ShippingItem { get; set; }
[SkipValuesOnUpdate]
public int? CreatorId { get; set; }
public int? ModifierId { get; set; }
[SkipValuesOnUpdate]
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
public bool IsValidMeasuringValues()
{
return ShippingItemId > 0 && Quantity > 0 && NetWeight > 0 && GrossWeight > 0;
}
}