fixes
This commit is contained in:
parent
a2ed202276
commit
a5e3702616
|
|
@ -1,12 +1,19 @@
|
|||
using AyCode.Core.Extensions;
|
||||
using AutoMapper;
|
||||
using AyCode.Core.Extensions;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Common;
|
||||
using Nop.Core.Domain.Orders;
|
||||
using Nop.Core.Domain.Shipping;
|
||||
|
||||
namespace Mango.Nop.Core.Dtos;
|
||||
|
||||
public abstract class MgOrderDto<TOrderItemDto, TProductDto> : ModelDtoBase<Order>, IMgOrderDto<TOrderItemDto, TProductDto> where TOrderItemDto : IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto
|
||||
public abstract class MgOrderDto<TOrderItemDto, TProductDto> : MgEntityBase, IModelDtoBase<Order>, IMgOrderDto<TOrderItemDto, TProductDto> where TOrderItemDto : IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto
|
||||
{
|
||||
public Guid OrderGuid { get; set; }
|
||||
public int StoreId { get; set; }
|
||||
|
|
@ -21,7 +28,9 @@ public abstract class MgOrderDto<TOrderItemDto, TProductDto> : ModelDtoBase<Orde
|
|||
public string CustomOrderNumber { get; set; }
|
||||
public string CustomValuesXml { get; set; }
|
||||
public bool Deleted { get; set; }
|
||||
public List<TOrderItemDto> OrderItemDtos { get; private set; }
|
||||
|
||||
[Association(ThisKey = nameof(Id), OtherKey = nameof(OrderItem.OrderId), CanBeNull = true)]
|
||||
public List<TOrderItemDto> OrderItemDtos { get; set; }
|
||||
|
||||
public OrderStatus OrderStatus
|
||||
{
|
||||
|
|
@ -36,38 +45,48 @@ public abstract class MgOrderDto<TOrderItemDto, TProductDto> : ModelDtoBase<Orde
|
|||
|
||||
protected MgOrderDto() :base()
|
||||
{ }
|
||||
protected MgOrderDto(int orderId) : base(orderId)
|
||||
{ }
|
||||
protected MgOrderDto(Order order) : base(order)
|
||||
{ }
|
||||
|
||||
public override void CopyDtoValuesToEntity(Order entity)
|
||||
protected MgOrderDto(int orderId)
|
||||
{
|
||||
base.CopyDtoValuesToEntity(entity);
|
||||
Id = orderId;
|
||||
}
|
||||
|
||||
protected MgOrderDto(Order order)
|
||||
{
|
||||
CopyEntityValuesToDto(order);
|
||||
}
|
||||
|
||||
public virtual void CopyDtoValuesToEntity(Order entity)
|
||||
{
|
||||
//var config = new MapperConfiguration(cfg =>
|
||||
//{
|
||||
// cfg.CreateMap<MgOrderDto<Order, Order>();
|
||||
// //cfg.CreateMap<Person, Person>()
|
||||
// // .ForMember(dest => dest.Address, opt => opt.MapFrom(src => _mapper.Map<Address>(src.Address)));
|
||||
//});
|
||||
//var _mapper = config.CreateMapper();
|
||||
//_mapper.Map<>
|
||||
PropertyHelper.CopyPublicValueTypeProperties(this, entity);
|
||||
}
|
||||
|
||||
public override void CopyEntityValuesToDto(Order entity)
|
||||
public virtual void CopyEntityValuesToDto(Order entity)
|
||||
{
|
||||
base.CopyEntityValuesToDto(entity);
|
||||
|
||||
PropertyHelper.CopyPublicValueTypeProperties(entity, this);
|
||||
}
|
||||
|
||||
public void CopyEntityValuesToDto(Order entity, List<TOrderItemDto> orderItemDtos)
|
||||
public virtual void CopyEntityValuesToDto(Order entity, List<TOrderItemDto> orderItemDtos)
|
||||
{
|
||||
CopyEntityValuesToDto(entity);
|
||||
|
||||
InitializeOrderItemDtos(orderItemDtos);
|
||||
}
|
||||
|
||||
public void InitializeOrderItemDtos(List<TOrderItemDto> orderItemDtos)
|
||||
public virtual void InitializeOrderItemDtos(List<TOrderItemDto> orderItemDtos)
|
||||
{
|
||||
OrderItemDtos = orderItemDtos;
|
||||
}
|
||||
|
||||
public override Order CreateMainEntity()
|
||||
public virtual Order CreateMainEntity()
|
||||
{
|
||||
//base.CreateMainEntity();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
using AyCode.Core.Extensions;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Orders;
|
||||
|
||||
namespace Mango.Nop.Core.Dtos;
|
||||
|
||||
public abstract class MgOrderItemDto<TProductDto> : ModelDtoBase<OrderItem>, IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto
|
||||
public abstract class MgOrderItemDto<TProductDto> : MgEntityBase, IModelDtoBase<OrderItem>, IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto
|
||||
{
|
||||
public Guid OrderItemGuid { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
|
|
@ -12,42 +15,46 @@ public abstract class MgOrderItemDto<TProductDto> : ModelDtoBase<OrderItem>, IMg
|
|||
public int Quantity { get; set; }
|
||||
public string AttributesXml { get; set; }
|
||||
public decimal? ItemWeight { get; set; }
|
||||
public TProductDto ProductDto { get; set; }
|
||||
|
||||
[Association(ThisKey = nameof(ProductId), OtherKey = nameof(Product.Id), CanBeNull = true)]
|
||||
public TProductDto? ProductDto { get; set; }
|
||||
|
||||
protected MgOrderItemDto() :base()
|
||||
{ }
|
||||
protected MgOrderItemDto(int orderItemId) : base(orderItemId)
|
||||
{ }
|
||||
protected MgOrderItemDto(OrderItem orderItem) : base(orderItem)
|
||||
{ }
|
||||
|
||||
public override void CopyDtoValuesToEntity(OrderItem entity)
|
||||
protected MgOrderItemDto(int orderItemId)
|
||||
{
|
||||
base.CopyDtoValuesToEntity(entity);
|
||||
Id = orderItemId;
|
||||
}
|
||||
|
||||
protected MgOrderItemDto(OrderItem orderItem)
|
||||
{
|
||||
CopyEntityValuesToDto(orderItem);
|
||||
}
|
||||
|
||||
public virtual void CopyDtoValuesToEntity(OrderItem entity)
|
||||
{
|
||||
PropertyHelper.CopyPublicValueTypeProperties(this, entity);
|
||||
}
|
||||
|
||||
public override void CopyEntityValuesToDto(OrderItem entity)
|
||||
public virtual void CopyEntityValuesToDto(OrderItem entity)
|
||||
{
|
||||
base.CopyEntityValuesToDto(entity);
|
||||
|
||||
PropertyHelper.CopyPublicValueTypeProperties(entity, this);
|
||||
}
|
||||
|
||||
public void CopyEntityValuesToDto(OrderItem entity, TProductDto productDto)
|
||||
public virtual void CopyEntityValuesToDto(OrderItem entity, TProductDto productDto)
|
||||
{
|
||||
CopyEntityValuesToDto(entity);
|
||||
|
||||
InitializeProductDto(productDto);
|
||||
}
|
||||
|
||||
public void InitializeProductDto(TProductDto productDto)
|
||||
public virtual void InitializeProductDto(TProductDto productDto)
|
||||
{
|
||||
ProductDto = productDto;
|
||||
}
|
||||
|
||||
public override OrderItem CreateMainEntity()
|
||||
public virtual OrderItem CreateMainEntity()
|
||||
{
|
||||
//base.CreateMainEntity();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
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 : ModelDtoBase<Product>, IMgProductDto//, IDiscountSupported<DiscountProductMapping>
|
||||
public abstract class MgProductDto : MgEntityBase, IModelDtoBase<Product>, IMgProductDto//, IDiscountSupported<DiscountProductMapping>
|
||||
{
|
||||
//public int Id { get; set; }
|
||||
public int ProductTypeId { get; set; }
|
||||
|
|
@ -27,14 +28,20 @@ public abstract class MgProductDto : ModelDtoBase<Product>, IMgProductDto//, IDi
|
|||
|
||||
protected MgProductDto() :base()
|
||||
{ }
|
||||
protected MgProductDto(int productId) : base(productId)
|
||||
{ }
|
||||
protected MgProductDto(Product product) : base(product)
|
||||
{ }
|
||||
|
||||
public override void CopyDtoValuesToEntity(Product entity)
|
||||
protected MgProductDto(int productId)
|
||||
{
|
||||
base.CopyDtoValuesToEntity(entity);
|
||||
Id = productId;
|
||||
}
|
||||
|
||||
protected MgProductDto(Product product)
|
||||
{
|
||||
CopyEntityValuesToDto(product);
|
||||
}
|
||||
|
||||
public virtual void CopyDtoValuesToEntity(Product entity)
|
||||
{
|
||||
entity.Id = Id;
|
||||
|
||||
entity.ProductTypeId = ProductTypeId;
|
||||
entity.ParentGroupedProductId = ParentGroupedProductId;
|
||||
|
|
@ -54,10 +61,9 @@ public abstract class MgProductDto : ModelDtoBase<Product>, IMgProductDto//, IDi
|
|||
entity.Deleted = Deleted;
|
||||
}
|
||||
|
||||
public override void CopyEntityValuesToDto(Product entity)
|
||||
public virtual void CopyEntityValuesToDto(Product entity)
|
||||
{
|
||||
base.CopyEntityValuesToDto(entity);
|
||||
|
||||
Id = entity.Id;
|
||||
ProductTypeId = entity.ProductTypeId;
|
||||
ParentGroupedProductId = entity.ParentGroupedProductId;
|
||||
|
||||
|
|
@ -76,7 +82,7 @@ public abstract class MgProductDto : ModelDtoBase<Product>, IMgProductDto//, IDi
|
|||
Deleted = entity.Deleted;
|
||||
}
|
||||
|
||||
public override Product CreateMainEntity()
|
||||
public virtual Product CreateMainEntity()
|
||||
{
|
||||
//base.CreateMainEntity();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public interface IMgOrderItemDto<TProductDto> : IEntityInt where TProductDto : I
|
|||
public string AttributesXml { get; set; }
|
||||
public decimal? ItemWeight { get; set; }
|
||||
|
||||
public TProductDto ProductDto { get; set; }
|
||||
public TProductDto? ProductDto { get; set; }
|
||||
|
||||
void InitializeProductDto(TProductDto productDto);
|
||||
void CopyEntityValuesToDto(OrderItem entity, TProductDto productDto);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="MessagePack.Annotations" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.9" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue