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

namespace IRaCIS.Core.Application.Service
{
    public class FinancialConfig : Profile
    {
        public FinancialConfig()
        {
            CreateMap<PaymentAdjustmentCommand, PaymentAdjustment>()
                .ForMember(t => t.YearMonthDate, u => u.MapFrom(t => t.YearMonth))
                .ForMember(t => t.YearMonth, u => u.MapFrom(t => t.YearMonth.ToString("yyyy-MM")));

            CreateMap<TrialPaymentPriceCommand, TrialPaymentPrice>();
            CreateMap<ReviewerPayInfoCommand, ReviewerPayInformation>();

            CreateMap<RankPriceCommand, RankPrice>();

            CreateMap<AwardPriceCommand, VolumeReward>();

            CreateMap<PaymentCommand, Payment>();

            CreateMap<PaymentDetailCommand, PaymentDetail>();
            CreateMap<ExchangeRateCommand, ExchangeRate>();

            CreateMap<AwardPriceCommand, VolumeReward>();

            CreateMap<TrialRevenuesPriceDTO, TrialRevenuesPrice>();

            CreateMap<TrialSOWPathDTO, TrialPaymentPrice>();


            CreateMap<RankPrice, RankPriceDTO>();
            CreateMap<VolumeReward, AwardPriceDTO>();
            CreateMap<RankPrice, RankDic>();
            CreateMap<ExchangeRate, ExchangeRateCommand>();
            CreateMap<Payment, CalculateNeededDTO>();

            CreateMap<VolumeReward, AwardPriceCalculateDTO>();
            CreateMap<PaymentDetail, PaymentDetailDTO>();

            CreateMap<TrialPaymentPrice, TrialSOWPathDTO>();


            CreateMap<TrialPaymentPrice, TrialPaymentPriceDTO>()
                .ForMember(t => t.TrialCode, u => u.MapFrom(t => t.Trial.Code))
                  .ForMember(t => t.ReviewMode, u => u.MapFrom(t => t.Trial.ReviewMode.Value))
                .ForMember(t => t.Cro, u => u.MapFrom(t => t.Trial.CRO.CROName))
                .ForMember(t => t.Indication, u => u.MapFrom(t => t.Trial.Indication))
                .ForMember(t => t.Expedited, u => u.MapFrom(t => t.Trial.Expedited))
                .ForMember(t => t.DoctorsNames, u => u.MapFrom(t => string.Join(',', t.Trial.EnrollList.Select(t => t.Doctor.ChineseName))))


                   ;
            
        }
    }
   
}