using AutoMapper; using Server.Models; using SharedModels.DataTransferObjects.Model; using Route = Server.Models.Route; namespace Server.Configurations; public class MapperInitializer : Profile { public MapperInitializer() { RecognizePostfixes("Utc"); RecognizeDestinationPostfixes("Utc"); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap() .ForMember(d => d.AddressName, opt => opt.MapFrom(src => src.Address.Name)) .ForMember(d => d.CityName, opt => opt.MapFrom(src => src.Address.City.Name)) .ForMember(d => d.StateName, opt => opt.MapFrom(src => src.Address.City.State.Name)) .ForMember(d => d.CountryName, opt => opt.MapFrom(src => src.Address.City.State.Country.Name)) .ForMember(d => d.FullName, opt => opt.MapFrom(src => src.Address.GetFullName())) .ForMember(d => d.Latitude, opt => opt.MapFrom(src => src.Address.Latitude)) .ForMember(d => d.Longitude, opt => opt.MapFrom(src => src.Address.Longitude)); CreateMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap() .ForMember(d => d.Addresses, opt => opt.MapFrom(src => src.VehicleEnrollment.Route.RouteAddresses.Select(ra => ra.Address))); CreateMap() .ForMember(d => d.DepartureAddressName, opt => opt.MapFrom(src => src.Tickets.First().GetDepartureAddress().Name)) .ForMember(d => d.DepartureCityName, opt => opt.MapFrom(src => src.Tickets.First().GetDepartureAddress().City.Name)) .ForMember(d => d.DepartureStateName, opt => opt.MapFrom(src => src.Tickets.First().GetDepartureAddress().City.State.Name)) .ForMember(d => d.DepartureCountryName, opt => opt.MapFrom(src => src.Tickets.First().GetDepartureAddress().City.State.Country.Name)) .ForMember(d => d.DepartureFullName, opt => opt.MapFrom(src => src.Tickets.First().GetDepartureAddress().GetFullName())) .ForMember(d => d.DepartureDateTime, opt => opt.MapFrom(src => src.Tickets.First().GetDepartureTime())) .ForMember(d => d.ArrivalAddressName, opt => opt.MapFrom(src => src.Tickets.Last().GetArrivalAddress().Name)) .ForMember(d => d.ArrivalCityName, opt => opt.MapFrom(src => src.Tickets.Last().GetArrivalAddress().City.Name)) .ForMember(d => d.ArrivalStateName, opt => opt.MapFrom(src => src.Tickets.Last().GetArrivalAddress().City.State.Name)) .ForMember(d => d.ArrivalCountryName, opt => opt.MapFrom(src => src.Tickets.Last().GetArrivalAddress().City.State.Country.Name)) .ForMember(d => d.ArrivalFullName, opt =>opt.MapFrom(src => src.Tickets.Last().GetArrivalAddress().GetFullName())) .ForMember(d => d.ArrivalDateTime, opt => opt.MapFrom(src => src.Tickets.Last().GetArrivalTime())); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ForMember(d => d.CompanyId, o => o.MapFrom(s => s.Employer.CompanyId)); CreateMap().ReverseMap(); CreateMap().ReverseMap(); } }