/// <summary> /// Fetch all of the parking lots and print them out /// </summary> private static async Task GetParkingLots() { Console.WriteLine("Testing '/api/parking-lots'"); List <ParkingLot> parkingLots = await ParkingLotApi.GetParkingLots(); Console.WriteLine("Got " + parkingLots.Count + " Parking Lots:"); foreach (ParkingLot parkingLot in parkingLots) { Console.WriteLine("--> " + parkingLot.Id + ": " + parkingLot.Name); } Console.WriteLine(); }
/// <summary> /// Insert a new parking lot named "TEST: C#-api-lot-insert" /// </summary> /// <returns>New parking lot's Id</returns> private static async Task <string> InsertParkingLot() { Console.WriteLine("Testing '/api/parking-lot/insert'"); const string parkingLotName = "TEST: C#-api-lot-insert"; // Sample JSON to send JObject json = new JObject { ["parkingLotName"] = parkingLotName, ["description"] = "c# client test", ["streetAddress"] = "123 here", ["latitude"] = 33.810280507079874, ["longitude"] = -117.9189795255661 }; await ParkingLotApi.InsertParkingLot(json.ToString()); Console.WriteLine("Parking Lot Insert Success"); // Get the parkingLotId of the inserted lot List <ParkingLot> parkingLots = await ParkingLotApi.GetParkingLots(); // Ideally the PlacePod API will include the id in the response message at a later time // so that we don't have to to a O(n) lookup... string parkingLotId = null; foreach (ParkingLot parkingLot in parkingLots) { if (parkingLot.Name == parkingLotName) { parkingLotId = parkingLot.Id; break; } } Console.WriteLine("ID of inserted parking lot: " + parkingLotId + "\n"); return(parkingLotId); }