58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using System.Linq.Expressions;
|
|
using NetinaShop.Domain.Dtos.SmallDtos;
|
|
using NetinaShop.Domain.Entities.Warehouses;
|
|
|
|
namespace NetinaShop.Domain.Mappers
|
|
{
|
|
public static partial class ShippingMapper
|
|
{
|
|
public static Shipping AdaptToShipping(this ShippingSDto p1)
|
|
{
|
|
return p1 == null ? null : new Shipping()
|
|
{
|
|
Id = p1.Id,
|
|
CreatedAt = p1.CreatedAt
|
|
};
|
|
}
|
|
public static Shipping AdaptTo(this ShippingSDto p2, Shipping p3)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Shipping result = p3 ?? new Shipping();
|
|
|
|
result.Id = p2.Id;
|
|
result.CreatedAt = p2.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static ShippingSDto AdaptToSDto(this Shipping p4)
|
|
{
|
|
return p4 == null ? null : new ShippingSDto()
|
|
{
|
|
Id = p4.Id,
|
|
CreatedAt = p4.CreatedAt
|
|
};
|
|
}
|
|
public static ShippingSDto AdaptTo(this Shipping p5, ShippingSDto p6)
|
|
{
|
|
if (p5 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ShippingSDto result = p6 ?? new ShippingSDto();
|
|
|
|
result.Id = p5.Id;
|
|
result.CreatedAt = p5.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Shipping, ShippingSDto>> ProjectToSDto => p7 => new ShippingSDto()
|
|
{
|
|
Id = p7.Id,
|
|
CreatedAt = p7.CreatedAt
|
|
};
|
|
}
|
|
} |