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); } }
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(); }); }
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)); } }