using AutoMapper;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Domain.Models;

namespace IRaCIS.Core.Application.Service
{
    public class InstitutionConfig : Profile
    {
        public InstitutionConfig()
        {
            var isEn_Us = false;

            CreateMap<HospitalCommand, Hospital>();
            CreateMap<SiteCommand, Site>();
            CreateMap<SponsorCommand, Sponsor>();

            CreateMap<Hospital, HospitalDTO>();
            CreateMap<CRO, CROCompanyDTO>().ReverseMap();
            CreateMap<Sponsor, SponsorDTO>();
            CreateMap<CRO, CroSelectDTO>()
                .ForMember(t => t.CROName, c => c.MapFrom(d => isEn_Us ? d.CROName : d.CRONameCN)); 

            CreateMap<Sponsor, SponsorSelectDTO>()
                .ForMember(t=>t.SponsorName,c=>c.MapFrom(d=> isEn_Us?d.SponsorName:d.SponsorNameCN));
            CreateMap<Site, SiteSelectionDTO>();


            //CreateMap<CRO, InstitutionDTO>()
            //    .ForMember(o => o.InstitutionName, t => t.MapFrom(u => u.CROName));
            //CreateMap<Sponsor, InstitutionDTO>()
            //    .ForMember(o => o.InstitutionName, t => t.MapFrom(u => u.SponsorName));
            //CreateMap<Hospital, InstitutionDTO>()
            //   .ForMember(o => o.InstitutionName, t => t.MapFrom(u => u.HospitalName));
            //CreateMap<Site, InstitutionDTO>()
            //   .ForMember(o => o.InstitutionName, t => t.MapFrom(u => u.SiteName));
        }
    }
   
}
