using System;
using System.Linq.Expressions;
using NetinaShop.Domain.Dtos.LargDtos;
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Products;

namespace NetinaShop.Domain.Mappers
{
    public static partial class ReviewMapper
    {
        public static Review AdaptToReview(this ReviewLDto p1)
        {
            return p1 == null ? null : new Review()
            {
                Title = p1.Title,
                Comment = p1.Comment,
                Rate = p1.Rate,
                IsBuyer = p1.IsBuyer,
                IsConfirmed = p1.IsConfirmed,
                ProductId = p1.ProductId,
                UserId = p1.UserId,
                Id = p1.Id,
                CreatedAt = p1.CreatedAt
            };
        }
        public static Review AdaptTo(this ReviewLDto 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.IsConfirmed = p2.IsConfirmed;
            result.ProductId = p2.ProductId;
            result.UserId = p2.UserId;
            result.Id = p2.Id;
            result.CreatedAt = p2.CreatedAt;
            return result;
            
        }
        public static Expression<Func<ReviewLDto, Review>> ProjectToReview => p4 => new Review()
        {
            Title = p4.Title,
            Comment = p4.Comment,
            Rate = p4.Rate,
            IsBuyer = p4.IsBuyer,
            IsConfirmed = p4.IsConfirmed,
            ProductId = p4.ProductId,
            UserId = p4.UserId,
            Id = p4.Id,
            CreatedAt = p4.CreatedAt
        };
        public static ReviewLDto AdaptToLDto(this Review p5)
        {
            return p5 == null ? null : new ReviewLDto()
            {
                Title = p5.Title,
                Comment = p5.Comment,
                Rate = p5.Rate,
                IsBuyer = p5.IsBuyer,
                IsConfirmed = p5.IsConfirmed,
                ProductId = p5.ProductId,
                UserId = p5.UserId,
                Id = p5.Id,
                CreatedAt = p5.CreatedAt
            };
        }
        public static ReviewLDto AdaptTo(this Review p6, ReviewLDto p7)
        {
            if (p6 == null)
            {
                return null;
            }
            ReviewLDto result = p7 ?? new ReviewLDto();
            
            result.Title = p6.Title;
            result.Comment = p6.Comment;
            result.Rate = p6.Rate;
            result.IsBuyer = p6.IsBuyer;
            result.IsConfirmed = p6.IsConfirmed;
            result.ProductId = p6.ProductId;
            result.UserId = p6.UserId;
            result.Id = p6.Id;
            result.CreatedAt = p6.CreatedAt;
            return result;
            
        }
        public static Expression<Func<Review, ReviewLDto>> ProjectToLDto => p8 => new ReviewLDto()
        {
            Title = p8.Title,
            Comment = p8.Comment,
            Rate = p8.Rate,
            IsBuyer = p8.IsBuyer,
            IsConfirmed = p8.IsConfirmed,
            ProductId = p8.ProductId,
            UserId = p8.UserId,
            Id = p8.Id,
            CreatedAt = p8.CreatedAt
        };
        public static Review AdaptToReview(this ReviewSDto p9)
        {
            return p9 == null ? null : new Review()
            {
                Title = p9.Title,
                Comment = p9.Comment,
                Rate = p9.Rate,
                IsBuyer = p9.IsBuyer,
                ProductId = p9.ProductId,
                UserId = p9.UserId,
                Id = p9.Id,
                CreatedAt = p9.CreatedAt
            };
        }
        public static Review AdaptTo(this ReviewSDto p10, Review p11)
        {
            if (p10 == null)
            {
                return null;
            }
            Review result = p11 ?? new Review();
            
            result.Title = p10.Title;
            result.Comment = p10.Comment;
            result.Rate = p10.Rate;
            result.IsBuyer = p10.IsBuyer;
            result.ProductId = p10.ProductId;
            result.UserId = p10.UserId;
            result.Id = p10.Id;
            result.CreatedAt = p10.CreatedAt;
            return result;
            
        }
        public static ReviewSDto AdaptToSDto(this Review p12)
        {
            return p12 == null ? null : new ReviewSDto()
            {
                Title = p12.Title,
                Comment = p12.Comment,
                Rate = p12.Rate,
                IsBuyer = p12.IsBuyer,
                ProductId = p12.ProductId,
                UserId = p12.UserId,
                Id = p12.Id,
                CreatedAt = p12.CreatedAt
            };
        }
        public static ReviewSDto AdaptTo(this Review p13, ReviewSDto p14)
        {
            if (p13 == null)
            {
                return null;
            }
            ReviewSDto result = p14 ?? new ReviewSDto();
            
            result.Title = p13.Title;
            result.Comment = p13.Comment;
            result.Rate = p13.Rate;
            result.IsBuyer = p13.IsBuyer;
            result.ProductId = p13.ProductId;
            result.UserId = p13.UserId;
            result.Id = p13.Id;
            result.CreatedAt = p13.CreatedAt;
            return result;
            
        }
        public static Expression<Func<Review, ReviewSDto>> ProjectToSDto => p15 => new ReviewSDto()
        {
            Title = p15.Title,
            Comment = p15.Comment,
            Rate = p15.Rate,
            IsBuyer = p15.IsBuyer,
            ProductId = p15.ProductId,
            UserId = p15.UserId,
            Id = p15.Id,
            CreatedAt = p15.CreatedAt
        };
    }
}