public SampleAppOne(IHttpAsync http) { _drivewayApi = new DrivewayApi(http); _parkingLotApi = new ParkingLotApi(http); _sensorApi = new SensorApi(http); _route = http.BaseRoute; }
public SampleAppOne(IHttpAsync http) { Driveways = new DrivewayApi(http); ParkingLots = new ParkingLotApi(http); Sensors = new SensorApi(http); Route = http.BaseRoute; }
/// <summary> /// Remove that updated parking lot /// </summary> /// <param name="parkingLotId">The Id of the updated parking lot</param> private static async Task RemoveParkingLot(string parkingLotId) { Console.WriteLine("Testing '/api/parking-lot/remove'"); // Sample JSON to send JObject json = new JObject { ["id"] = parkingLotId }; await ParkingLotApi.RemoveParkingLot(json.ToString()); Console.WriteLine("Parking Lot Remove Success\n"); }
/// <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> /// Update that new parking lot's name to "TEST: C#-api-lot-update" /// </summary> /// <param name="parkingLotId">Id of the new parking lot</param> private static async Task UpdateParkingLot(string parkingLotId) { Console.WriteLine("Testing '/api/parking-lot/update'"); // Sample JSON to send JObject json = new JObject { ["id"] = parkingLotId, ["parkingLotName"] = "TEST: C#-api-lot-update" }; await ParkingLotApi.UpdateParkingLot(json.ToString()); Console.WriteLine("Parking Lot Update Success\n"); }
public IHttpActionResult UpdateName(ParkingLotUpdateViewModel model) { try { var parkingLotApi = new ParkingLotApi(); parkingLotApi.UpdateName(model); return(Json(new ResultModel { success = true, })); } catch (Exception ex) { return(Json(new ResultModel { success = false, })); } }
public IHttpActionResult GetParkingLotsByAreaId(int areaId) { try { ParkingLotApi parkingLotApi = new ParkingLotApi(); var listParkingLot = parkingLotApi.GetParkingLotsByAreaId(areaId); return(Json(new ResultModel { obj = listParkingLot, success = true, })); } catch (Exception ex) { return(Json(new ResultModel { success = false, })); } }
public IHttpActionResult UpdateStatus(ParkingLotUpdateViewModel model) { try { var parkingLotApi = new ParkingLotApi(); parkingLotApi.UpdateStatus(model); return(Json(new ResultModel { message = "Cập nhập thành công", success = true, })); } catch (Exception ex) { return(Json(new ResultModel { message = "Có lỗi xảy ra, vui lòng liên hệ admin", success = false, })); } }
/// <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); }
public IHttpActionResult UpdateMultiStatus(IEnumerable <ParkingLotUpdateViewModel> model) { try { var parkingLotApi = new ParkingLotApi(); foreach (var item in model) { parkingLotApi.UpdateStatus(item); } return(Json(new ResultModel { message = "Cập nhập thành công", success = true, })); } catch (Exception ex) { return(Json(new ResultModel { message = "Có lỗi xảy ra, vui lòng liên hệ admin", success = false, })); } }