示例#1
0
        public ActionResult GetAllAircraftsAsync(int day)
        {
            //Make sur to dispose all ressources event if
            using (AircraftService aircraftService = new AircraftService(_flightManagerDbContext))
            {
                //Call to the database
                var aircrafts = aircraftService.GetAllAvailableAircrafts(day);

                //Configure the serialization to send the json in CamelCase
                JsonSerializerSettings settings = new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                };
                //Json serialization
                string json = JsonConvert.SerializeObject(aircrafts, settings);

                //Return http request as OK with serialized aiport list
                return(Ok(json));
            }
        }