using System;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.Hospitals;

namespace DocuMed.Domain.Mappers
{
    public static partial class HospitalMapper
    {
        public static Hospital AdaptToHospital(this HospitalSDto p1)
        {
            return p1 == null ? null : new Hospital()
            {
                Name = p1.Name,
                Detail = p1.Detail,
                Address = p1.Address,
                Id = p1.Id
            };
        }
        public static Hospital AdaptTo(this HospitalSDto p2, Hospital p3)
        {
            if (p2 == null)
            {
                return null;
            }
            Hospital result = p3 ?? new Hospital();
            
            result.Name = p2.Name;
            result.Detail = p2.Detail;
            result.Address = p2.Address;
            result.Id = p2.Id;
            return result;
            
        }
        public static Expression<Func<HospitalSDto, Hospital>> ProjectToHospital => p4 => new Hospital()
        {
            Name = p4.Name,
            Detail = p4.Detail,
            Address = p4.Address,
            Id = p4.Id
        };
        public static HospitalSDto AdaptToSDto(this Hospital p5)
        {
            return p5 == null ? null : new HospitalSDto()
            {
                Name = p5.Name,
                Detail = p5.Detail,
                Address = p5.Address,
                UniversityName = p5.University == null ? null : p5.University.Name,
                Id = p5.Id
            };
        }
        public static HospitalSDto AdaptTo(this Hospital p6, HospitalSDto p7)
        {
            if (p6 == null)
            {
                return null;
            }
            HospitalSDto result = p7 ?? new HospitalSDto();
            
            result.Name = p6.Name;
            result.Detail = p6.Detail;
            result.Address = p6.Address;
            result.UniversityName = p6.University == null ? null : p6.University.Name;
            result.Id = p6.Id;
            return result;
            
        }
        public static Expression<Func<Hospital, HospitalSDto>> ProjectToSDto => p8 => new HospitalSDto()
        {
            Name = p8.Name,
            Detail = p8.Detail,
            Address = p8.Address,
            UniversityName = p8.University.Name,
            Id = p8.Id
        };
    }
}