示例#1
0
        public async Task <ActionResult <IEnumerable <Flight> > > GetAllFlights([FromQuery(Name = "relative_to")]  DateTime relativeTo)
        {
            string requestStr = Request.QueryString.Value;
            bool   isExternal = requestStr.Contains("sync_all");

            // convert the time to utc
            //DateTime convertedTime = TimeZoneInfo.ConvertTimeToUtc(relativeTo);
            DateTime convertedTime = relativeTo;

            try
            {
                // return the correct list according to the "sync_all"
                if (isExternal)
                {
                    IEnumerable <Flight> flights = await this.flightsModel.GetAllFlights(convertedTime)
                    ;

                    return(CreatedAtAction(actionName: "GetAllFlights", flights));
                }
                else
                {
                    return(CreatedAtAction(actionName: "GetAllFlights", await flightsModel.GetAllInternalFlights(convertedTime)));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }