using AutoMapper;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
using salesbook.Shared.Core.Entity;

namespace salesbook.Shared.Core.Helpers;

public class MappingProfile : Profile
{
    public MappingProfile()
    {
        CreateMap<StbActivity, ActivityDTO>();

        // Mapping da AnagClie a ContactDTO
        CreateMap<AnagClie, ContactDTO>()
            .ForMember(dest => dest.CodContact, opt => opt.MapFrom(src => src.CodAnag))
            .ForMember(dest => dest.IsContact, opt => opt.MapFrom(src => true));

        // Mapping da PtbPros a ContactDTO
        CreateMap<PtbPros, ContactDTO>()
            .ForMember(dest => dest.CodContact, opt => opt.MapFrom(src => src.CodPpro))
            .ForMember(dest => dest.IsContact, opt => opt.MapFrom(src => false));

        //Mapping da VtbCliePersRif a PersRifDTO
        CreateMap<VtbCliePersRif, PersRifDTO>()
            .ForMember(x => x.CodPersRif, y => y.MapFrom(z => z.CodAnag));

        //Mapping da PtbProsRif a PersRifDTO
        CreateMap<PtbProsRif, PersRifDTO>()
            .ForMember(x => x.CodPersRif, y => y.MapFrom(z => z.CodPpro));
    }
}
