Api/NetinaShop.Domain/Mappers/ReviewMapper.g.cs

83 lines
2.4 KiB
C#

using System;
using System.Linq.Expressions;
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Products;
namespace NetinaShop.Domain.Mappers
{
public static partial class ReviewMapper
{
public static Review AdaptToReview(this ReviewSDto p1)
{
return p1 == null ? null : new Review()
{
Title = p1.Title,
Comment = p1.Comment,
Rate = p1.Rate,
IsBuyer = p1.IsBuyer,
ProductId = p1.ProductId,
UserId = p1.UserId,
Id = p1.Id
};
}
public static Review AdaptTo(this ReviewSDto p2, Review p3)
{
if (p2 == null)
{
return null;
}
Review result = p3 ?? new Review();
result.Title = p2.Title;
result.Comment = p2.Comment;
result.Rate = p2.Rate;
result.IsBuyer = p2.IsBuyer;
result.ProductId = p2.ProductId;
result.UserId = p2.UserId;
result.Id = p2.Id;
return result;
}
public static ReviewSDto AdaptToSDto(this Review p4)
{
return p4 == null ? null : new ReviewSDto()
{
Title = p4.Title,
Comment = p4.Comment,
Rate = p4.Rate,
IsBuyer = p4.IsBuyer,
ProductId = p4.ProductId,
UserId = p4.UserId,
Id = p4.Id
};
}
public static ReviewSDto AdaptTo(this Review p5, ReviewSDto p6)
{
if (p5 == null)
{
return null;
}
ReviewSDto result = p6 ?? new ReviewSDto();
result.Title = p5.Title;
result.Comment = p5.Comment;
result.Rate = p5.Rate;
result.IsBuyer = p5.IsBuyer;
result.ProductId = p5.ProductId;
result.UserId = p5.UserId;
result.Id = p5.Id;
return result;
}
public static Expression<Func<Review, ReviewSDto>> ProjectToSDto => p7 => new ReviewSDto()
{
Title = p7.Title,
Comment = p7.Comment,
Rate = p7.Rate,
IsBuyer = p7.IsBuyer,
ProductId = p7.ProductId,
UserId = p7.UserId,
Id = p7.Id
};
}
}