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

namespace Netina.Domain.Mappers
{
    public static partial class UserAddressMapper
    {
        public static UserAddress AdaptToUserAddress(this UserAddressSDto p1)
        {
            return p1 == null ? null : new UserAddress()
            {
                Address = p1.Address,
                PostalCode = p1.PostalCode,
                ReceiverFullName = p1.ReceiverFullName,
                ReceiverPhoneNumber = p1.ReceiverPhoneNumber,
                LocationLat = p1.LocationLat,
                LocationLong = p1.LocationLong,
                Province = p1.Province,
                City = p1.City,
                Plaque = p1.Plaque,
                BuildingUnit = p1.BuildingUnit,
                UserId = p1.UserId,
                Id = p1.Id,
                CreatedAt = p1.CreatedAt
            };
        }
        public static UserAddress AdaptTo(this UserAddressSDto p2, UserAddress p3)
        {
            if (p2 == null)
            {
                return null;
            }
            UserAddress result = p3 ?? new UserAddress();
            
            result.Address = p2.Address;
            result.PostalCode = p2.PostalCode;
            result.ReceiverFullName = p2.ReceiverFullName;
            result.ReceiverPhoneNumber = p2.ReceiverPhoneNumber;
            result.LocationLat = p2.LocationLat;
            result.LocationLong = p2.LocationLong;
            result.Province = p2.Province;
            result.City = p2.City;
            result.Plaque = p2.Plaque;
            result.BuildingUnit = p2.BuildingUnit;
            result.UserId = p2.UserId;
            result.Id = p2.Id;
            result.CreatedAt = p2.CreatedAt;
            return result;
            
        }
        public static UserAddressSDto AdaptToSDto(this UserAddress p4)
        {
            return p4 == null ? null : new UserAddressSDto()
            {
                Address = p4.Address,
                PostalCode = p4.PostalCode,
                ReceiverFullName = p4.ReceiverFullName,
                ReceiverPhoneNumber = p4.ReceiverPhoneNumber,
                LocationLat = p4.LocationLat,
                LocationLong = p4.LocationLong,
                Province = p4.Province,
                City = p4.City,
                Plaque = p4.Plaque,
                BuildingUnit = p4.BuildingUnit,
                UserId = p4.UserId,
                Id = p4.Id,
                CreatedAt = p4.CreatedAt
            };
        }
        public static UserAddressSDto AdaptTo(this UserAddress p5, UserAddressSDto p6)
        {
            if (p5 == null)
            {
                return null;
            }
            UserAddressSDto result = p6 ?? new UserAddressSDto();
            
            result.Address = p5.Address;
            result.PostalCode = p5.PostalCode;
            result.ReceiverFullName = p5.ReceiverFullName;
            result.ReceiverPhoneNumber = p5.ReceiverPhoneNumber;
            result.LocationLat = p5.LocationLat;
            result.LocationLong = p5.LocationLong;
            result.Province = p5.Province;
            result.City = p5.City;
            result.Plaque = p5.Plaque;
            result.BuildingUnit = p5.BuildingUnit;
            result.UserId = p5.UserId;
            result.Id = p5.Id;
            result.CreatedAt = p5.CreatedAt;
            return result;
            
        }
        public static Expression<Func<UserAddress, UserAddressSDto>> ProjectToSDto => p7 => new UserAddressSDto()
        {
            Address = p7.Address,
            PostalCode = p7.PostalCode,
            ReceiverFullName = p7.ReceiverFullName,
            ReceiverPhoneNumber = p7.ReceiverPhoneNumber,
            LocationLat = p7.LocationLat,
            LocationLong = p7.LocationLong,
            Province = p7.Province,
            City = p7.City,
            Plaque = p7.Plaque,
            BuildingUnit = p7.BuildingUnit,
            UserId = p7.UserId,
            Id = p7.Id,
            CreatedAt = p7.CreatedAt
        };
    }
}