using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using BookingMockService.Entity;

namespace BookingMockService
{
    public class BookingService : IBookingService
    {
        public AvailabilityResponse GetAvailability(AvailabilityRequest request)
        {
            AvailabilityResponse result = new AvailabilityResponse();
            List<Journey> inboundJourneyList = new List<Journey>();
            Journey j1 = new Journey();
            j1.DepartureTime = request.DepartureDate;
            j1.ArrivalStation = new Location();
            j1.ArrivalStation.Code = "00";
            j1.ArrivalStation.Name = string.Format("{0} Airport", request.Destination);
            j1.ArrivalTime = request.DepartureDate.AddHours(1);
            j1.Carrier = string.Format("{0} Airways", request.Origin);
            j1.DepartureStation = new Location();
            j1.DepartureStation.Code = "01";
            j1.DepartureStation.Name = string.Format("{0} Airport", request.Origin);
            j1.DepartureTime = request.DepartureDate.AddHours(10);
            j1.Key = "AAA";
            j1.Number = "1111";

            inboundJourneyList.Add(j1);
            result.InboundJourneys = inboundJourneyList;

            List<Journey> outboundJourneyList = new List<Journey>();
            Journey j2 = new Journey();
            j2.DepartureTime = request.DepartureDate;
            j2.ArrivalStation = new Location();
            j2.ArrivalStation.Code = "01";
            j2.ArrivalStation.Name = string.Format("{0} Airport", request.Origin);
            j2.ArrivalTime = request.ReturnDate.AddHours(1);
            j2.Carrier = string.Format("{0} Airways", request.Destination);
            j2.DepartureStation = new Location();
            j2.DepartureStation.Code = "01";
            j2.DepartureStation.Name = string.Format("{0} Airport", request.Destination);
            j2.DepartureTime = request.ReturnDate.AddHours(10);
            j2.Key = "AAA";
            j2.Number = "1111";
            outboundJourneyList.Add(j2);
            result.OutoundJourneys = outboundJourneyList;
            return result;
        }
    }
}
