using AutoMapper;
using Lada.Framework.Data.Domains.Premises;
using Ladaer.BackEnd.Infrastructures.DTO.Items.Premises;
using Ladaer.BackEnd.Infrastructures.DTO.Models.Premises;
using Ladaer.BackEnd.Infrastructures.DTO.Results.Premises;

namespace Ladaer.BackEnd.Infrastructures.DTO.Profiles
{
    public class PremiseMappingProfile : Profile
    {
        public PremiseMappingProfile()
        {
            // Premise
            CreateMap<PremiseModel, Premise>();
            CreateMap<Premise, PremiseModel>();
            CreateMap<Premise, PremiseItem>()
                .ForMember(dest => dest.AgencyName, opt => opt.MapFrom(src => src.Agency != null ? src.Agency.Name : ""))
                .ForMember(dest => dest.CityName, opt => opt.MapFrom(src => src.City != null ? src.City.Name : ""))
                .ForMember(dest => dest.DistrictName, opt => opt.MapFrom(src => src.District != null ? src.District.Name : ""))
                .ForMember(dest => dest.WardName, opt => opt.MapFrom(src => src.Ward != null ? src.Ward.Name : ""));

            // PremiseFinancial
            CreateMap<PremiseFinancialModel, PremiseFinancial>();
            CreateMap<PremiseFinancial, PremiseFinancialModel>();
            CreateMap<PremiseFinancial, PremiseFinancialDetail>();

            // PremiseContact
            CreateMap<PremiseContactModel, PremiseContact>();
            CreateMap<PremiseContact, PremiseContactModel>();
            CreateMap<PremiseContact, PremiseContactDetail>();
            CreateMap<PremiseContact, PremiseContactItem>();

            // PremiseScore
            CreateMap<PremiseScoreModel, PremiseScore>();
            CreateMap<PremiseScore, PremiseScoreModel>();
            CreateMap<PremiseScore, PremiseScoreDetail>();
            CreateMap<PremiseScore, PremiseScoreItem>();

            // PremiseScoringCriteria
            CreateMap<PremiseScoringCriteriaModel, PremiseScoringCriteria>()
                .ForMember(dest => dest.Options, opt => opt.Ignore());
            CreateMap<PremiseScoringCriteria, PremiseScoringCriteriaModel>();
            CreateMap<PremiseScoringCriteria, PremiseScoringCriteriaItem>();

            // PremiseScoringOption
            CreateMap<PremiseScoringOptionModel, PremiseScoringOption>();
            CreateMap<PremiseScoringOption, PremiseScoringOptionModel>();
            CreateMap<PremiseScoringOption, PremiseScoringOptionItem>();
        }
    }
}
