Mango.Nop.Libraries/Mango.Nop.Core/Dtos/MgProductDto.cs

98 lines
2.6 KiB
C#

using AyCode.Interfaces.Entities;
using Mango.Nop.Core.Entities;
using Mango.Nop.Core.Interfaces;
using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Discounts;
namespace Mango.Nop.Core.Dtos;
public abstract class MgProductDto : MgEntityBase, IModelDtoBase<Product>, IMgProductDto//, IDiscountSupported<DiscountProductMapping>
{
//public int Id { get; set; }
public int ProductTypeId { get; set; }
public int ParentGroupedProductId { get; set; }
public string Name { get; set; }
public string ShortDescription { get; set; }
public string FullDescription { get; set; }
public int WarehouseId { get; set; }
public int StockQuantity { get; set; }
public decimal ProductCost { get; set; }
public decimal Weight { get; set; }
public decimal Length { get; set; }
public decimal Width { get; set; }
public decimal Height { get; set; }
public bool Deleted { get; set; }
protected MgProductDto() :base()
{ }
protected MgProductDto(int productId)
{
Id = productId;
}
protected MgProductDto(Product product)
{
CopyEntityValuesToDto(product);
}
public virtual void CopyDtoValuesToEntity(Product entity)
{
entity.Id = Id;
entity.ProductTypeId = ProductTypeId;
entity.ParentGroupedProductId = ParentGroupedProductId;
entity.Name = Name;
entity.ShortDescription = ShortDescription;
entity.FullDescription = FullDescription;
entity.WarehouseId = WarehouseId;
entity.StockQuantity = StockQuantity;
entity.Weight = Weight;
entity.Length = Length;
entity.Width = Width;
entity.Height = Height;
entity.Deleted = Deleted;
}
public virtual void CopyEntityValuesToDto(Product entity)
{
Id = entity.Id;
ProductTypeId = entity.ProductTypeId;
ParentGroupedProductId = entity.ParentGroupedProductId;
Name = entity.Name;
ShortDescription = entity.ShortDescription;
FullDescription = entity.FullDescription;
WarehouseId = entity.WarehouseId;
StockQuantity = entity.StockQuantity;
Weight = entity.Weight;
Length = entity.Length;
Width = entity.Width;
Height = entity.Height;
Deleted = entity.Deleted;
}
public virtual Product CreateMainEntity()
{
//base.CreateMainEntity();
var product = new Product();
CopyDtoValuesToEntity(product);
return product;
}
public bool SubjectToAcl { get; set; }
public bool LimitedToStores { get; set; }
}