326 lines
13 KiB
C#
326 lines
13 KiB
C#
using System;
|
|
using System.Linq.Expressions;
|
|
using Netina.Domain.Dtos.LargDtos;
|
|
using Netina.Domain.Dtos.SmallDtos;
|
|
using Netina.Domain.Entities.Discounts;
|
|
|
|
namespace Netina.Domain.Mappers
|
|
{
|
|
public static partial class DiscountMapper
|
|
{
|
|
public static Discount AdaptToDiscount(this DiscountLDto p1)
|
|
{
|
|
return p1 == null ? null : new Discount()
|
|
{
|
|
Code = p1.Code,
|
|
Description = p1.Description,
|
|
DiscountPercent = p1.DiscountPercent,
|
|
DiscountAmount = p1.DiscountAmount,
|
|
HasCode = p1.HasCode,
|
|
AmountType = p1.AmountType,
|
|
Type = p1.Type,
|
|
Count = p1.Count,
|
|
StartDate = p1.StartDate,
|
|
ExpireDate = p1.ExpireDate,
|
|
Immortal = p1.Immortal,
|
|
PriceFloor = p1.PriceFloor,
|
|
HasPriceFloor = p1.HasPriceFloor,
|
|
PriceCeiling = p1.PriceCeiling,
|
|
HasPriceCeiling = p1.HasPriceCeiling,
|
|
IsInfinity = p1.IsInfinity,
|
|
UseCount = p1.UseCount,
|
|
IsSpecialOffer = p1.IsSpecialOffer,
|
|
IsForInvitation = p1.IsForInvitation,
|
|
IsForFirstPurchase = p1.IsForFirstPurchase,
|
|
Id = p1.Id,
|
|
CreatedAt = p1.CreatedAt
|
|
};
|
|
}
|
|
public static Discount AdaptTo(this DiscountLDto p2, Discount p3)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Discount result = p3 ?? new Discount();
|
|
|
|
result.Code = p2.Code;
|
|
result.Description = p2.Description;
|
|
result.DiscountPercent = p2.DiscountPercent;
|
|
result.DiscountAmount = p2.DiscountAmount;
|
|
result.HasCode = p2.HasCode;
|
|
result.AmountType = p2.AmountType;
|
|
result.Type = p2.Type;
|
|
result.Count = p2.Count;
|
|
result.StartDate = p2.StartDate;
|
|
result.ExpireDate = p2.ExpireDate;
|
|
result.Immortal = p2.Immortal;
|
|
result.PriceFloor = p2.PriceFloor;
|
|
result.HasPriceFloor = p2.HasPriceFloor;
|
|
result.PriceCeiling = p2.PriceCeiling;
|
|
result.HasPriceCeiling = p2.HasPriceCeiling;
|
|
result.IsInfinity = p2.IsInfinity;
|
|
result.UseCount = p2.UseCount;
|
|
result.IsSpecialOffer = p2.IsSpecialOffer;
|
|
result.IsForInvitation = p2.IsForInvitation;
|
|
result.IsForFirstPurchase = p2.IsForFirstPurchase;
|
|
result.Id = p2.Id;
|
|
result.CreatedAt = p2.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<DiscountLDto, Discount>> ProjectToDiscount => p4 => new Discount()
|
|
{
|
|
Code = p4.Code,
|
|
Description = p4.Description,
|
|
DiscountPercent = p4.DiscountPercent,
|
|
DiscountAmount = p4.DiscountAmount,
|
|
HasCode = p4.HasCode,
|
|
AmountType = p4.AmountType,
|
|
Type = p4.Type,
|
|
Count = p4.Count,
|
|
StartDate = p4.StartDate,
|
|
ExpireDate = p4.ExpireDate,
|
|
Immortal = p4.Immortal,
|
|
PriceFloor = p4.PriceFloor,
|
|
HasPriceFloor = p4.HasPriceFloor,
|
|
PriceCeiling = p4.PriceCeiling,
|
|
HasPriceCeiling = p4.HasPriceCeiling,
|
|
IsInfinity = p4.IsInfinity,
|
|
UseCount = p4.UseCount,
|
|
IsSpecialOffer = p4.IsSpecialOffer,
|
|
IsForInvitation = p4.IsForInvitation,
|
|
IsForFirstPurchase = p4.IsForFirstPurchase,
|
|
Id = p4.Id,
|
|
CreatedAt = p4.CreatedAt
|
|
};
|
|
public static DiscountLDto AdaptToLDto(this Discount p5)
|
|
{
|
|
return p5 == null ? null : new DiscountLDto()
|
|
{
|
|
Code = p5.Code,
|
|
Description = p5.Description,
|
|
DiscountPercent = p5.DiscountPercent,
|
|
DiscountAmount = p5.DiscountAmount,
|
|
HasCode = p5.HasCode,
|
|
AmountType = p5.AmountType,
|
|
Type = p5.Type,
|
|
Count = p5.Count,
|
|
StartDate = p5.StartDate,
|
|
ExpireDate = p5.ExpireDate,
|
|
Immortal = p5.Immortal,
|
|
PriceFloor = p5.PriceFloor,
|
|
HasPriceFloor = p5.HasPriceFloor,
|
|
PriceCeiling = p5.PriceCeiling,
|
|
HasPriceCeiling = p5.HasPriceCeiling,
|
|
IsInfinity = p5.IsInfinity,
|
|
UseCount = p5.UseCount,
|
|
IsSpecialOffer = p5.IsSpecialOffer,
|
|
IsForInvitation = p5.IsForInvitation,
|
|
IsForFirstPurchase = p5.IsForFirstPurchase,
|
|
Id = p5.Id,
|
|
CreatedAt = p5.CreatedAt
|
|
};
|
|
}
|
|
public static DiscountLDto AdaptTo(this Discount p6, DiscountLDto p7)
|
|
{
|
|
if (p6 == null)
|
|
{
|
|
return null;
|
|
}
|
|
DiscountLDto result = p7 ?? new DiscountLDto();
|
|
|
|
result.Code = p6.Code;
|
|
result.Description = p6.Description;
|
|
result.DiscountPercent = p6.DiscountPercent;
|
|
result.DiscountAmount = p6.DiscountAmount;
|
|
result.HasCode = p6.HasCode;
|
|
result.AmountType = p6.AmountType;
|
|
result.Type = p6.Type;
|
|
result.Count = p6.Count;
|
|
result.StartDate = p6.StartDate;
|
|
result.ExpireDate = p6.ExpireDate;
|
|
result.Immortal = p6.Immortal;
|
|
result.PriceFloor = p6.PriceFloor;
|
|
result.HasPriceFloor = p6.HasPriceFloor;
|
|
result.PriceCeiling = p6.PriceCeiling;
|
|
result.HasPriceCeiling = p6.HasPriceCeiling;
|
|
result.IsInfinity = p6.IsInfinity;
|
|
result.UseCount = p6.UseCount;
|
|
result.IsSpecialOffer = p6.IsSpecialOffer;
|
|
result.IsForInvitation = p6.IsForInvitation;
|
|
result.IsForFirstPurchase = p6.IsForFirstPurchase;
|
|
result.Id = p6.Id;
|
|
result.CreatedAt = p6.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Discount, DiscountLDto>> ProjectToLDto => p8 => new DiscountLDto()
|
|
{
|
|
Code = p8.Code,
|
|
Description = p8.Description,
|
|
DiscountPercent = p8.DiscountPercent,
|
|
DiscountAmount = p8.DiscountAmount,
|
|
HasCode = p8.HasCode,
|
|
AmountType = p8.AmountType,
|
|
Type = p8.Type,
|
|
Count = p8.Count,
|
|
StartDate = p8.StartDate,
|
|
ExpireDate = p8.ExpireDate,
|
|
Immortal = p8.Immortal,
|
|
PriceFloor = p8.PriceFloor,
|
|
HasPriceFloor = p8.HasPriceFloor,
|
|
PriceCeiling = p8.PriceCeiling,
|
|
HasPriceCeiling = p8.HasPriceCeiling,
|
|
IsInfinity = p8.IsInfinity,
|
|
UseCount = p8.UseCount,
|
|
IsSpecialOffer = p8.IsSpecialOffer,
|
|
IsForInvitation = p8.IsForInvitation,
|
|
IsForFirstPurchase = p8.IsForFirstPurchase,
|
|
Id = p8.Id,
|
|
CreatedAt = p8.CreatedAt
|
|
};
|
|
public static Discount AdaptToDiscount(this DiscountSDto p9)
|
|
{
|
|
return p9 == null ? null : new Discount()
|
|
{
|
|
Code = p9.Code,
|
|
Description = p9.Description,
|
|
DiscountPercent = p9.DiscountPercent,
|
|
DiscountAmount = p9.DiscountAmount,
|
|
HasCode = p9.HasCode,
|
|
AmountType = p9.AmountType,
|
|
Type = p9.Type,
|
|
Count = p9.Count,
|
|
StartDate = p9.StartDate,
|
|
ExpireDate = p9.ExpireDate,
|
|
PriceFloor = p9.PriceFloor,
|
|
HasPriceFloor = p9.HasPriceFloor,
|
|
PriceCeiling = p9.PriceCeiling,
|
|
HasPriceCeiling = p9.HasPriceCeiling,
|
|
IsInfinity = p9.IsInfinity,
|
|
UseCount = p9.UseCount,
|
|
IsSpecialOffer = p9.IsSpecialOffer,
|
|
IsForInvitation = p9.IsForInvitation,
|
|
IsForFirstPurchase = p9.IsForFirstPurchase,
|
|
Id = p9.Id,
|
|
CreatedAt = p9.CreatedAt
|
|
};
|
|
}
|
|
public static Discount AdaptTo(this DiscountSDto p10, Discount p11)
|
|
{
|
|
if (p10 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Discount result = p11 ?? new Discount();
|
|
|
|
result.Code = p10.Code;
|
|
result.Description = p10.Description;
|
|
result.DiscountPercent = p10.DiscountPercent;
|
|
result.DiscountAmount = p10.DiscountAmount;
|
|
result.HasCode = p10.HasCode;
|
|
result.AmountType = p10.AmountType;
|
|
result.Type = p10.Type;
|
|
result.Count = p10.Count;
|
|
result.StartDate = p10.StartDate;
|
|
result.ExpireDate = p10.ExpireDate;
|
|
result.PriceFloor = p10.PriceFloor;
|
|
result.HasPriceFloor = p10.HasPriceFloor;
|
|
result.PriceCeiling = p10.PriceCeiling;
|
|
result.HasPriceCeiling = p10.HasPriceCeiling;
|
|
result.IsInfinity = p10.IsInfinity;
|
|
result.UseCount = p10.UseCount;
|
|
result.IsSpecialOffer = p10.IsSpecialOffer;
|
|
result.IsForInvitation = p10.IsForInvitation;
|
|
result.IsForFirstPurchase = p10.IsForFirstPurchase;
|
|
result.Id = p10.Id;
|
|
result.CreatedAt = p10.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static DiscountSDto AdaptToSDto(this Discount p12)
|
|
{
|
|
return p12 == null ? null : new DiscountSDto()
|
|
{
|
|
Code = p12.Code,
|
|
Description = p12.Description,
|
|
DiscountPercent = p12.DiscountPercent,
|
|
DiscountAmount = p12.DiscountAmount,
|
|
HasCode = p12.HasCode,
|
|
AmountType = p12.AmountType,
|
|
Type = p12.Type,
|
|
Count = p12.Count,
|
|
StartDate = p12.StartDate,
|
|
ExpireDate = p12.ExpireDate,
|
|
PriceFloor = p12.PriceFloor,
|
|
HasPriceFloor = p12.HasPriceFloor,
|
|
PriceCeiling = p12.PriceCeiling,
|
|
HasPriceCeiling = p12.HasPriceCeiling,
|
|
IsInfinity = p12.IsInfinity,
|
|
UseCount = p12.UseCount,
|
|
IsSpecialOffer = p12.IsSpecialOffer,
|
|
IsForInvitation = p12.IsForInvitation,
|
|
IsForFirstPurchase = p12.IsForFirstPurchase,
|
|
Id = p12.Id,
|
|
CreatedAt = p12.CreatedAt
|
|
};
|
|
}
|
|
public static DiscountSDto AdaptTo(this Discount p13, DiscountSDto p14)
|
|
{
|
|
if (p13 == null)
|
|
{
|
|
return null;
|
|
}
|
|
DiscountSDto result = p14 ?? new DiscountSDto();
|
|
|
|
result.Code = p13.Code;
|
|
result.Description = p13.Description;
|
|
result.DiscountPercent = p13.DiscountPercent;
|
|
result.DiscountAmount = p13.DiscountAmount;
|
|
result.HasCode = p13.HasCode;
|
|
result.AmountType = p13.AmountType;
|
|
result.Type = p13.Type;
|
|
result.Count = p13.Count;
|
|
result.StartDate = p13.StartDate;
|
|
result.ExpireDate = p13.ExpireDate;
|
|
result.PriceFloor = p13.PriceFloor;
|
|
result.HasPriceFloor = p13.HasPriceFloor;
|
|
result.PriceCeiling = p13.PriceCeiling;
|
|
result.HasPriceCeiling = p13.HasPriceCeiling;
|
|
result.IsInfinity = p13.IsInfinity;
|
|
result.UseCount = p13.UseCount;
|
|
result.IsSpecialOffer = p13.IsSpecialOffer;
|
|
result.IsForInvitation = p13.IsForInvitation;
|
|
result.IsForFirstPurchase = p13.IsForFirstPurchase;
|
|
result.Id = p13.Id;
|
|
result.CreatedAt = p13.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Discount, DiscountSDto>> ProjectToSDto => p15 => new DiscountSDto()
|
|
{
|
|
Code = p15.Code,
|
|
Description = p15.Description,
|
|
DiscountPercent = p15.DiscountPercent,
|
|
DiscountAmount = p15.DiscountAmount,
|
|
HasCode = p15.HasCode,
|
|
AmountType = p15.AmountType,
|
|
Type = p15.Type,
|
|
Count = p15.Count,
|
|
StartDate = p15.StartDate,
|
|
ExpireDate = p15.ExpireDate,
|
|
PriceFloor = p15.PriceFloor,
|
|
HasPriceFloor = p15.HasPriceFloor,
|
|
PriceCeiling = p15.PriceCeiling,
|
|
HasPriceCeiling = p15.HasPriceCeiling,
|
|
IsInfinity = p15.IsInfinity,
|
|
UseCount = p15.UseCount,
|
|
IsSpecialOffer = p15.IsSpecialOffer,
|
|
IsForInvitation = p15.IsForInvitation,
|
|
IsForFirstPurchase = p15.IsForFirstPurchase,
|
|
Id = p15.Id,
|
|
CreatedAt = p15.CreatedAt
|
|
};
|
|
}
|
|
} |