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

namespace NetinaShop.Domain.Mappers
{
    public static partial class ShippingMapper
    {
        public static Shipping AdaptToShipping(this ShippingSDto p1)
        {
            return p1 == null ? null : new Shipping()
            {
                Name = p1.Name,
                WarehouseName = p1.WarehouseName,
                IsExpressShipping = p1.IsExpressShipping,
                IsShipBySeller = p1.IsShipBySeller,
                IsOriginalWarehouse = p1.IsOriginalWarehouse,
                DeliveryCost = p1.DeliveryCost,
                WorkingDays = p1.WorkingDays,
                Id = p1.Id,
                CreatedAt = p1.CreatedAt
            };
        }
        public static Shipping AdaptTo(this ShippingSDto p2, Shipping p3)
        {
            if (p2 == null)
            {
                return null;
            }
            Shipping result = p3 ?? new Shipping();
            
            result.Name = p2.Name;
            result.WarehouseName = p2.WarehouseName;
            result.IsExpressShipping = p2.IsExpressShipping;
            result.IsShipBySeller = p2.IsShipBySeller;
            result.IsOriginalWarehouse = p2.IsOriginalWarehouse;
            result.DeliveryCost = p2.DeliveryCost;
            result.WorkingDays = p2.WorkingDays;
            result.Id = p2.Id;
            result.CreatedAt = p2.CreatedAt;
            return result;
            
        }
        public static ShippingSDto AdaptToSDto(this Shipping p4)
        {
            return p4 == null ? null : new ShippingSDto()
            {
                Name = p4.Name,
                WarehouseName = p4.WarehouseName,
                IsExpressShipping = p4.IsExpressShipping,
                IsShipBySeller = p4.IsShipBySeller,
                IsOriginalWarehouse = p4.IsOriginalWarehouse,
                DeliveryCost = p4.DeliveryCost,
                WorkingDays = p4.WorkingDays,
                Id = p4.Id,
                CreatedAt = p4.CreatedAt
            };
        }
        public static ShippingSDto AdaptTo(this Shipping p5, ShippingSDto p6)
        {
            if (p5 == null)
            {
                return null;
            }
            ShippingSDto result = p6 ?? new ShippingSDto();
            
            result.Name = p5.Name;
            result.WarehouseName = p5.WarehouseName;
            result.IsExpressShipping = p5.IsExpressShipping;
            result.IsShipBySeller = p5.IsShipBySeller;
            result.IsOriginalWarehouse = p5.IsOriginalWarehouse;
            result.DeliveryCost = p5.DeliveryCost;
            result.WorkingDays = p5.WorkingDays;
            result.Id = p5.Id;
            result.CreatedAt = p5.CreatedAt;
            return result;
            
        }
        public static Expression<Func<Shipping, ShippingSDto>> ProjectToSDto => p7 => new ShippingSDto()
        {
            Name = p7.Name,
            WarehouseName = p7.WarehouseName,
            IsExpressShipping = p7.IsExpressShipping,
            IsShipBySeller = p7.IsShipBySeller,
            IsOriginalWarehouse = p7.IsOriginalWarehouse,
            DeliveryCost = p7.DeliveryCost,
            WorkingDays = p7.WorkingDays,
            Id = p7.Id,
            CreatedAt = p7.CreatedAt
        };
    }
}