using System;
using System.Linq.Expressions;
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Users;

namespace NetinaShop.Domain.Mappers
{
    public static partial class NewsletterMemberMapper
    {
        public static NewsletterMember AdaptToNewsletterMember(this NewsletterMemberSDto p1)
        {
            return p1 == null ? null : new NewsletterMember()
            {
                PhoneNumber = p1.PhoneNumber,
                Email = p1.Email,
                Id = p1.Id,
                CreatedAt = p1.CreatedAt
            };
        }
        public static NewsletterMember AdaptTo(this NewsletterMemberSDto p2, NewsletterMember p3)
        {
            if (p2 == null)
            {
                return null;
            }
            NewsletterMember result = p3 ?? new NewsletterMember();
            
            result.PhoneNumber = p2.PhoneNumber;
            result.Email = p2.Email;
            result.Id = p2.Id;
            result.CreatedAt = p2.CreatedAt;
            return result;
            
        }
        public static NewsletterMemberSDto AdaptToSDto(this NewsletterMember p4)
        {
            return p4 == null ? null : new NewsletterMemberSDto()
            {
                PhoneNumber = p4.PhoneNumber,
                Email = p4.Email,
                Id = p4.Id,
                CreatedAt = p4.CreatedAt
            };
        }
        public static NewsletterMemberSDto AdaptTo(this NewsletterMember p5, NewsletterMemberSDto p6)
        {
            if (p5 == null)
            {
                return null;
            }
            NewsletterMemberSDto result = p6 ?? new NewsletterMemberSDto();
            
            result.PhoneNumber = p5.PhoneNumber;
            result.Email = p5.Email;
            result.Id = p5.Id;
            result.CreatedAt = p5.CreatedAt;
            return result;
            
        }
        public static Expression<Func<NewsletterMember, NewsletterMemberSDto>> ProjectToSDto => p7 => new NewsletterMemberSDto()
        {
            PhoneNumber = p7.PhoneNumber,
            Email = p7.Email,
            Id = p7.Id,
            CreatedAt = p7.CreatedAt
        };
    }
}