using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BookingModule.Entity;
using Entity = BookingModule.Entity.AvailabilityResponse;
using Service = ThirdPartyBookingFeature.ThirdPartyBookingServiceReference.AvailabilityResponse;
using EntityJourney = BookingModule.Entity.Journey;
using ServiceJourney = ThirdPartyBookingFeature.ThirdPartyBookingServiceReference.Journey;

namespace ThirdPartyBookingFeature.Mapping
{
    public static class AvailabilityResponseMap
    {
        public static Entity ServiceToEntity(Service source)
        {
            Entity result = new Entity();
            result.InboundJourneys = new List<EntityJourney>();
            foreach (ServiceJourney inboundJourney in source.InboundJourneys)
            {
                result.InboundJourneys.Add(JourneyMap.ServiceToEntity(inboundJourney));
            }
            result.OutboundJourneys = new List<EntityJourney>();
            foreach (ServiceJourney outboundJourney in source.OutoundJourneys)
            {
                result.OutboundJourneys.Add(JourneyMap.ServiceToEntity(outboundJourney));
            }
            return result;
        }

        public static Service EntityToService(Entity source)
        {
            Service result = new Service();
            result.InboundJourneys = new List<ServiceJourney>();
            foreach (EntityJourney inboundJourney in source.InboundJourneys)
            {
                result.InboundJourneys.Add(JourneyMap.EntityToService(inboundJourney));
            }
            result.OutoundJourneys = new List<ServiceJourney>();
            foreach (EntityJourney outboundJourney in source.OutboundJourneys)
            {
                result.OutoundJourneys.Add(JourneyMap.EntityToService(outboundJourney));
            }
            return result;
        }
    }
}
