From 96eb509ec5ff7bcf459b96ee6fcaa28cb7848b51 Mon Sep 17 00:00:00 2001 From: Loretta Date: Tue, 30 Sep 2025 18:18:22 +0200 Subject: [PATCH] improvements, fixes, etc... --- Mango.Nop.Core/Dtos/IModelDtoBase.cs | 6 +++++- Mango.Nop.Core/Dtos/ProductDto.cs | 24 +++++++++++++++++---- Mango.Nop.Core/Interfaces/IProductDto.cs | 27 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 Mango.Nop.Core/Interfaces/IProductDto.cs diff --git a/Mango.Nop.Core/Dtos/IModelDtoBase.cs b/Mango.Nop.Core/Dtos/IModelDtoBase.cs index 3d4fa08..1d440ed 100644 --- a/Mango.Nop.Core/Dtos/IModelDtoBase.cs +++ b/Mango.Nop.Core/Dtos/IModelDtoBase.cs @@ -12,7 +12,11 @@ public interface IModelDtoBase : IEntityInt, IModelDtoBaseEmpty { } -public interface IModelDtoBase : IModelDtoBase where TMainEntity : BaseEntity +public interface IModelDtoBase : IModelDtoBase where TMainEntity : BaseEntity { TMainEntity CreateMainEntity(); + + void CopyDtoValuesToEntity(TMainEntity entity); + + void CopyEntityValuesToDto(TMainEntity entity); } \ No newline at end of file diff --git a/Mango.Nop.Core/Dtos/ProductDto.cs b/Mango.Nop.Core/Dtos/ProductDto.cs index 6606c2d..c930c95 100644 --- a/Mango.Nop.Core/Dtos/ProductDto.cs +++ b/Mango.Nop.Core/Dtos/ProductDto.cs @@ -1,10 +1,13 @@ -using Nop.Core.Domain.Catalog; -using Nop.Core.Domain.Common; +using AyCode.Interfaces.Entities; +using Mango.Nop.Core.Interfaces; +using Nop.Core.Domain.Catalog; +using Nop.Core.Domain.Discounts; namespace Mango.Nop.Core.Dtos; -public class ProductDto : ModelDtoBase, ISoftDeletedEntity +public class ProductDto : ModelDtoBase, IProductDto//, IDiscountSupported { + //public int Id { get; set; } public int ProductTypeId { get; set; } public int ParentGroupedProductId { get; set; } @@ -24,7 +27,7 @@ public class ProductDto : ModelDtoBase, ISoftDeletedEntity public ProductDto() :base() { } - public ProductDto(int product) : base(product) + public ProductDto(int productId) : base(productId) { } public ProductDto(Product product) : base(product) { } @@ -72,4 +75,17 @@ public class ProductDto : ModelDtoBase, ISoftDeletedEntity Deleted = entity.Deleted; } + + public override Product CreateMainEntity() + { + //base.CreateMainEntity(); + + var product = new Product(); + CopyDtoValuesToEntity(product); + + return product; + } + + public bool SubjectToAcl { get; set; } + public bool LimitedToStores { get; set; } } \ No newline at end of file diff --git a/Mango.Nop.Core/Interfaces/IProductDto.cs b/Mango.Nop.Core/Interfaces/IProductDto.cs new file mode 100644 index 0000000..9036b6f --- /dev/null +++ b/Mango.Nop.Core/Interfaces/IProductDto.cs @@ -0,0 +1,27 @@ +using AyCode.Interfaces.Entities; +using Nop.Core.Domain.Common; +using Nop.Core.Domain.Discounts; +using Nop.Core.Domain.Localization; +using Nop.Core.Domain.Security; +using Nop.Core.Domain.Seo; +using Nop.Core.Domain.Stores; + +namespace Mango.Nop.Core.Interfaces; + +public interface IProductDto : IEntityInt, ILocalizedEntity, ISlugSupported, IAclSupported, IStoreMappingSupported/*, IDiscountSupported*/, ISoftDeletedEntity +{ + int ProductTypeId { get; set; } + int ParentGroupedProductId { get; set; } + + string Name { get; set; } + string ShortDescription { get; set; } + string FullDescription { get; set; } + + int WarehouseId { get; set; } + int StockQuantity { get; set; } + + decimal Weight { get; set; } + decimal Length { get; set; } + decimal Width { get; set; } + decimal Height { get; set; } +} \ No newline at end of file