public FlightsModule(SchedulerRepository repository)
            : base("/flights")
        {
            // Get all flights
            Get["/"] = _ => repository.GetSchedule().Flights
                .Select(f => new
                {
                    f.Flight,
                    f.Arrives,
                    f.Departs
                });

            // Get all flights
            Get["/unscheduled"] = _ => repository.GetSchedule().Flights
                .Where(f => f.Gate == null)
                .Select(f => new
                {
                    f.Flight,
                    f.Arrives,
                    f.Departs
                });

            // Add flights
            Post["/"] = parameters =>
            {
                // This API POSTs a list of flights at a time instead of individual flights.
                var flights = this.Bind<IEnumerable<FlightModel>>().ToList();
                var schedule = repository.GetSchedule();
                schedule.AddFlights(flights);
                schedule.ScheduleUnassignedFlights();
                repository.SaveSchedule(schedule);
                return null;
            };
        }
        /// <summary>
        /// Create Gates Module. The constructor is called by the IoC container
        /// instead of by our own code.
        /// </summary>
        public GatesModule(SchedulerRepository repository)
            : base("/gates")
        {
            // This tells the web server to use the provided delegate (Lambda)
            // to serve a GET request at this endpoint.
            Get["/"] = _ => repository.GetSchedule().Gates
                .Select(g => new
                {
                    g.Gate
                });

            Post["/"] = _ =>
            {
                var gates = this.Bind<IEnumerable<GateModel>>();
                var schedule = repository.GetSchedule();
                schedule.AddGates(gates.ToArray());
                repository.SaveSchedule(schedule);
                return null;
            };
        }