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

namespace NetinaShop.Domain.Mappers
{
    public static partial class StorageFileMapper
    {
        public static StorageFile AdaptToStorageFile(this StorageFileSDto p1)
        {
            return p1 == null ? null : new StorageFile()
            {
                Name = p1.Name,
                FileLocation = p1.FileLocation,
                FileName = p1.FileName,
                IsHeader = p1.IsHeader,
                IsPrimary = p1.IsPrimary,
                FileType = p1.FileType,
                Id = p1.Id,
                CreatedAt = p1.CreatedAt
            };
        }
        public static StorageFile AdaptTo(this StorageFileSDto p2, StorageFile p3)
        {
            if (p2 == null)
            {
                return null;
            }
            StorageFile result = p3 ?? new StorageFile();
            
            result.Name = p2.Name;
            result.FileLocation = p2.FileLocation;
            result.FileName = p2.FileName;
            result.IsHeader = p2.IsHeader;
            result.IsPrimary = p2.IsPrimary;
            result.FileType = p2.FileType;
            result.Id = p2.Id;
            result.CreatedAt = p2.CreatedAt;
            return result;
            
        }
        public static StorageFileSDto AdaptToSDto(this StorageFile p4)
        {
            return p4 == null ? null : new StorageFileSDto()
            {
                Name = p4.Name,
                FileLocation = p4.FileLocation,
                FileName = p4.FileName,
                IsHeader = p4.IsHeader,
                IsPrimary = p4.IsPrimary,
                FileType = p4.FileType,
                Id = p4.Id
            };
        }
        public static StorageFileSDto AdaptTo(this StorageFile p5, StorageFileSDto p6)
        {
            if (p5 == null)
            {
                return null;
            }
            StorageFileSDto result = p6 ?? new StorageFileSDto();
            
            result.Name = p5.Name;
            result.FileLocation = p5.FileLocation;
            result.FileName = p5.FileName;
            result.IsHeader = p5.IsHeader;
            result.IsPrimary = p5.IsPrimary;
            result.FileType = p5.FileType;
            result.Id = p5.Id;
            return result;
            
        }
        public static Expression<Func<StorageFile, StorageFileSDto>> ProjectToSDto => p7 => new StorageFileSDto()
        {
            Name = p7.Name,
            FileLocation = p7.FileLocation,
            FileName = p7.FileName,
            IsHeader = p7.IsHeader,
            IsPrimary = p7.IsPrimary,
            FileType = p7.FileType,
            Id = p7.Id
        };
    }
}