コード例 #1
0
        public void GetAllAirportsTest()
        {
            AirportService service = new AirportService(new TestAirportRepository(new Airport {
                Name = "Name", Code = "Code", City = "City", TimeZone = 999
            }), new TestUnitOfWork());
            var airports = service.GetAllAirports();

            foreach (var airport in airports)
            {
                Assert.AreEqual(airport.Code, "Code");
                Assert.AreEqual(airport.City, "City");
                Assert.AreEqual(airport.Name, "Name");
                Assert.AreEqual(airport.TimeZone, 999);
            }
        }
コード例 #2
0
        private void LoadSavedAirports()
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                var airports = await AirportService.GetAllAirports(new System.Threading.CancellationToken()).ConfigureAwait(false);
                foreach (var airport in airports)
                {
                    var item = Airports.FirstOrDefault(x => x.Name == airport.Name);
                    if (item != null)
                    {
                        continue;
                    }

                    Airports.Add(airport);
                }
                HasSavedItems = Airports != null && Airports.Any();
            });
        }
コード例 #3
0
        public ActionResult GetAllAirportsAsync()
        {
            //Make sur to dispose all ressources event if
            using (AirportService airportService = new AirportService(_flightManagerDbContext))
            {
                //Call to the database
                var airports = airportService.GetAllAirports();

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

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