public HttpResponseMessage Get(int id)
        {
            var flight = Flights.GetFlight(id);

            var flightDTO = new FlightWithSchedulesDTO
            {
                FlightNumber = flight.FlightNumber,
                FlightId     = flight.FlightId,
                Source       = flight.Source.ToLocationDTO(),
                Destination  = flight.Destination.ToLocationDTO(),
                Schedules    =
                    from s in flight.Schedules
                    select new FlightScheduleDTO
                {
                    // Departure is saved as the local time, but we need to
                    // calculate the local arrival time according to
                    // the origin and destination of the flight, and its duration
                    FlightScheduleId = s.FlightScheduleId,
                    Departure        = s.Departure,
                    Duration         = s.Duration,
                    Arrival          = GetArrivalDate(s.Departure, s.Duration, flight.Source, flight.Destination),
                }
            };

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, flightDTO);

            return(response);
        }
Exemplo n.º 2
0
        private SyndicationFeed CreateFeed(FlightWithSchedulesDTO flight)
        {
            var feed = new SyndicationFeed
            {
                Title = new TextSyndicationContent(string.Format("Blue Yonder flight {0}", flight.FlightNumber))
            };
            var items = from s in flight.Schedules
                        select new SyndicationItem
            {
                Title = new TextSyndicationContent(
                    String.Format("Flight {0} {1}", flight.FlightNumber, s.Departure.ToString("MMMM dd, yyyy"))),
                Id      = flight.FlightNumber,
                BaseUri = new Uri(_request.RequestUri,
                                  string.Format("{0}/{1}", _request.RequestUri.AbsolutePath, flight.FlightNumber)),
            };

            feed.Items = items;
            return(feed);
        }