using System;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.User;

namespace Brizco.Domain.Mappers
{
    public static partial class ApplicationUserMapper
    {
        public static ApplicationUser AdaptToApplicationUser(this ApplicationUserSDto p1)
        {
            return p1 == null ? null : new ApplicationUser()
            {
                FirstName = p1.FirstName,
                LastName = p1.LastName,
                NationalId = p1.NationalId,
                BirthDate = p1.BirthDate,
                Gender = p1.Gender,
                SignUpStatus = p1.SignUpStatus,
                Id = p1.Id,
                PhoneNumber = p1.PhoneNumber
            };
        }
        public static ApplicationUser AdaptTo(this ApplicationUserSDto p2, ApplicationUser p3)
        {
            if (p2 == null)
            {
                return null;
            }
            ApplicationUser result = p3 ?? new ApplicationUser();
            
            result.FirstName = p2.FirstName;
            result.LastName = p2.LastName;
            result.NationalId = p2.NationalId;
            result.BirthDate = p2.BirthDate;
            result.Gender = p2.Gender;
            result.SignUpStatus = p2.SignUpStatus;
            result.Id = p2.Id;
            result.PhoneNumber = p2.PhoneNumber;
            return result;
            
        }
        public static Expression<Func<ApplicationUserSDto, ApplicationUser>> ProjectToApplicationUser => p4 => new ApplicationUser()
        {
            FirstName = p4.FirstName,
            LastName = p4.LastName,
            NationalId = p4.NationalId,
            BirthDate = p4.BirthDate,
            Gender = p4.Gender,
            SignUpStatus = p4.SignUpStatus,
            Id = p4.Id,
            PhoneNumber = p4.PhoneNumber
        };
        public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p5)
        {
            return p5 == null ? null : new ApplicationUserSDto()
            {
                PhoneNumber = p5.PhoneNumber,
                FirstName = p5.FirstName,
                LastName = p5.LastName,
                BirthDate = p5.BirthDate,
                Gender = p5.Gender,
                SignUpStatus = p5.SignUpStatus,
                NationalId = p5.NationalId,
                Id = p5.Id
            };
        }
        public static ApplicationUserSDto AdaptTo(this ApplicationUser p6, ApplicationUserSDto p7)
        {
            if (p6 == null)
            {
                return null;
            }
            ApplicationUserSDto result = p7 ?? new ApplicationUserSDto();
            
            result.PhoneNumber = p6.PhoneNumber;
            result.FirstName = p6.FirstName;
            result.LastName = p6.LastName;
            result.BirthDate = p6.BirthDate;
            result.Gender = p6.Gender;
            result.SignUpStatus = p6.SignUpStatus;
            result.NationalId = p6.NationalId;
            result.Id = p6.Id;
            return result;
            
        }
        public static Expression<Func<ApplicationUser, ApplicationUserSDto>> ProjectToSDto => p8 => new ApplicationUserSDto()
        {
            PhoneNumber = p8.PhoneNumber,
            FirstName = p8.FirstName,
            LastName = p8.LastName,
            BirthDate = p8.BirthDate,
            Gender = p8.Gender,
            SignUpStatus = p8.SignUpStatus,
            NationalId = p8.NationalId,
            Id = p8.Id
        };
    }
}