115 lines
4.4 KiB
C#
115 lines
4.4 KiB
C#
using System;
|
|
using System.Linq.Expressions;
|
|
using Netina.Domain.Dtos.ResponseDtos.Torob;
|
|
using Netina.Domain.Dtos.SmallDtos;
|
|
using Netina.Domain.Entities.Products;
|
|
|
|
namespace Netina.Domain.Mappers
|
|
{
|
|
public static partial class SubProductMapper
|
|
{
|
|
public static SubProduct AdaptToSubProduct(this SubProductSDto p1)
|
|
{
|
|
return p1 == null ? null : new SubProduct()
|
|
{
|
|
ParentId = (Guid?)p1.ParentId,
|
|
Diversity = p1.Diversity,
|
|
DiversityValue = p1.DiversityValue,
|
|
DiversityDescription = p1.DiversityDescription,
|
|
PersianName = p1.PersianName,
|
|
Cost = p1.Cost,
|
|
PackingCost = p1.PackingCost,
|
|
Stock = p1.Stock,
|
|
HasExpressDelivery = p1.HasExpressDelivery,
|
|
MaxOrderCount = p1.MaxOrderCount,
|
|
Id = p1.Id,
|
|
CreatedAt = p1.CreatedAt
|
|
};
|
|
}
|
|
public static SubProduct AdaptTo(this SubProductSDto p2, SubProduct p3)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
SubProduct result = p3 ?? new SubProduct();
|
|
|
|
result.ParentId = (Guid?)p2.ParentId;
|
|
result.Diversity = p2.Diversity;
|
|
result.DiversityValue = p2.DiversityValue;
|
|
result.DiversityDescription = p2.DiversityDescription;
|
|
result.PersianName = p2.PersianName;
|
|
result.Cost = p2.Cost;
|
|
result.PackingCost = p2.PackingCost;
|
|
result.Stock = p2.Stock;
|
|
result.HasExpressDelivery = p2.HasExpressDelivery;
|
|
result.MaxOrderCount = p2.MaxOrderCount;
|
|
result.Id = p2.Id;
|
|
result.CreatedAt = p2.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static SubProductSDto AdaptToSDto(this SubProduct p4)
|
|
{
|
|
return p4 == null ? null : new SubProductSDto()
|
|
{
|
|
ParentId = p4.ParentId == null ? default(Guid) : (Guid)p4.ParentId,
|
|
PersianName = p4.PersianName,
|
|
Cost = p4.Cost,
|
|
Stock = p4.Stock,
|
|
MaxOrderCount = p4.MaxOrderCount,
|
|
PackingCost = p4.PackingCost,
|
|
HasExpressDelivery = p4.HasExpressDelivery,
|
|
Diversity = p4.Diversity,
|
|
DiversityValue = p4.DiversityValue,
|
|
DiversityDescription = p4.DiversityDescription,
|
|
Id = p4.Id,
|
|
CreatedAt = p4.CreatedAt
|
|
};
|
|
}
|
|
public static SubProductSDto AdaptTo(this SubProduct p5, SubProductSDto p6)
|
|
{
|
|
if (p5 == null)
|
|
{
|
|
return null;
|
|
}
|
|
SubProductSDto result = p6 ?? new SubProductSDto();
|
|
|
|
result.ParentId = p5.ParentId == null ? default(Guid) : (Guid)p5.ParentId;
|
|
result.PersianName = p5.PersianName;
|
|
result.Cost = p5.Cost;
|
|
result.Stock = p5.Stock;
|
|
result.MaxOrderCount = p5.MaxOrderCount;
|
|
result.PackingCost = p5.PackingCost;
|
|
result.HasExpressDelivery = p5.HasExpressDelivery;
|
|
result.Diversity = p5.Diversity;
|
|
result.DiversityValue = p5.DiversityValue;
|
|
result.DiversityDescription = p5.DiversityDescription;
|
|
result.Id = p5.Id;
|
|
result.CreatedAt = p5.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<SubProduct, SubProductSDto>> ProjectToSDto => p7 => new SubProductSDto()
|
|
{
|
|
ParentId = p7.ParentId == null ? default(Guid) : (Guid)p7.ParentId,
|
|
PersianName = p7.PersianName,
|
|
Cost = p7.Cost,
|
|
Stock = p7.Stock,
|
|
MaxOrderCount = p7.MaxOrderCount,
|
|
PackingCost = p7.PackingCost,
|
|
HasExpressDelivery = p7.HasExpressDelivery,
|
|
Diversity = p7.Diversity,
|
|
DiversityValue = p7.DiversityValue,
|
|
DiversityDescription = p7.DiversityDescription,
|
|
Id = p7.Id,
|
|
CreatedAt = p7.CreatedAt
|
|
};
|
|
public static Expression<Func<SubProduct, TorobProductResponseDto>> ProjectToTorobProductResponseDto => p8 => new TorobProductResponseDto()
|
|
{
|
|
product_id = ((Product)p8).Id.ToString(),
|
|
price = p8.Cost,
|
|
availibility = p8.IsEnable
|
|
};
|
|
}
|
|
} |