62 lines
2.4 KiB
C#
62 lines
2.4 KiB
C#
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 Nop.Core.Domain.Catalog;
|
|
using DataType = LinqToDB.DataType;
|
|
|
|
namespace FruitBank.Common.Entities;
|
|
|
|
[Table(Name = FruitBankConstClient.ShippingItemDbTableName)]
|
|
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingItemDbTableName)]
|
|
public class ShippingItem : MgEntityBase, IShippingItem
|
|
{
|
|
public int? ProductId { get; set; }
|
|
//[Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(Shipping.Id))]
|
|
//public IEnumerable<Shipping> Shippings { get; set; }
|
|
|
|
public int ShippingDocumentId { get; set; }
|
|
public string Name { get; set; }
|
|
|
|
public int Quantity { get; set; }
|
|
|
|
[Column(DataType = DataType.DecFloat)] public double NetWeight { get; set; }
|
|
[Column(DataType = DataType.DecFloat)] public double GrossWeight { get; set; }
|
|
|
|
|
|
[Nullable]
|
|
[Column(CanBeNull = true)]
|
|
[Range(1, 100000, ErrorMessage = "The MeasuredQuantity value should be a number between 1 and 100,000.")]
|
|
public int? MeasuredQuantity { get; set; }
|
|
|
|
[Nullable]
|
|
[Column(DataType = DataType.DecFloat, CanBeNull = true)]
|
|
[Range(1, 100000, ErrorMessage = "The MeasuredNetWeight value should be a number between 1 and 100,000.")]
|
|
public double? MeasuredNetWeight { get; set; }
|
|
|
|
[Nullable]
|
|
[Column(DataType = DataType.DecFloat, CanBeNull = true)]
|
|
[Range(1, 100000, ErrorMessage = "The MeasuredGrossWeight value should be a number between 1 and 100,000.")]
|
|
public double? MeasuredGrossWeight { get; set; }
|
|
|
|
public bool IsMeasurable { get; set; }
|
|
public bool IsMeasured { get; set; }
|
|
|
|
[LinqToDB.Mapping.Association(ThisKey = nameof(ProductId), OtherKey = nameof(Product.Id), CanBeNull = true)]
|
|
public Product? Product { get; set; }
|
|
|
|
[LinqToDB.Mapping.Association(ThisKey = nameof(ShippingDocumentId), OtherKey = nameof(ShippingDocument.Id), CanBeNull = true)]
|
|
public ShippingDocument? ShippingDocument { get; set; }
|
|
|
|
[SkipValuesOnUpdate] public DateTime Created { get; set; }
|
|
public DateTime Modified { get; set; }
|
|
|
|
public bool IsValidMeasuringValues()
|
|
{
|
|
return /*ProductId > 0 && */MeasuredQuantity > 0 && (!IsMeasurable || (MeasuredNetWeight > 0 && MeasuredGrossWeight > 0));
|
|
}
|
|
} |