using CMSMicroservice.Application.CityCQ.Queries.GetAllCitiesByFilter;
using Mapster;
using ProtoCity = CMSMicroservice.Protobuf.Protos.City;
using AppCity = CMSMicroservice.Application.CityCQ.Queries.GetAllCitiesByFilter;

namespace CMSMicroservice.WebApi.Common.Mappings;

public class CityProfile : IRegister
{
    void IRegister.Register(TypeAdapterConfig config)
    {
        // Request: Proto → Application
        config.NewConfig<ProtoCity.GetAllCitiesByFilterRequest, AppCity.GetAllCitiesByFilterQuery>()
            .Map(dest => dest.PaginationState, src => src.PaginationState)
            .Map(dest => dest.SortBy, src => src.SortBy)
            .Map(dest => dest.Filter, src => src.Filter);

        config.NewConfig<ProtoCity.GetAllCitiesByFilterFilter, AppCity.GetAllCitiesByFilterFilter>()
            .Map(dest => dest.Id, src => src.Id)
            .Map(dest => dest.Name, src => src.Name)
            .Map(dest => dest.Native, src => src.Native)
            .Map(dest => dest.StateId, src => src.StateId);

        // Response: Application → Proto
        config.NewConfig<AppCity.GetAllCitiesByFilterResponseDto, ProtoCity.GetAllCitiesByFilterResponse>()
            .Map(dest => dest.MetaData, src => src.MetaData)
            .Map(dest => dest.Cities, src => src.Models);

        config.NewConfig<AppCity.GetAllCitiesByFilterResponseModel, ProtoCity.CityDto>()
            .Map(dest => dest.Id, src => src.Id)
            .Map(dest => dest.ExternalId, src => src.ExternalId)
            .Map(dest => dest.Name, src => src.Name)
            .Map(dest => dest.Native, src => src.Native)
            .Map(dest => dest.Latitude, src => src.Latitude)
            .Map(dest => dest.Longitude, src => src.Longitude)
            .Map(dest => dest.StateId, src => src.StateId)
            .Map(dest => dest.StateName, src => src.StateName)
            .Map(dest => dest.StateNative, src => src.StateNative);
    }
}
