public IActionResult ParkingLot(string id) { int newId = _dataProtector.Unprotect(id); ResponseDetails response = _apiHelper.SendApiRequest("", "parkinglot/get/" + newId, HttpMethod.Get); if (response.Success) { ParkingLotViewModel model = JsonConvert.DeserializeObject <ParkingLotViewModel> (response.Data.ToString()); _dataProtector.ProtectParkingLotRouteValues(model); model.SlotViewModels = model.SlotViewModels.Select(x => { // populate can book property logic x.CanBook = CanBookSlot(x); _dataProtector.ProtectSlotRouteValues(x); return(x); }).ToList(); return(View(model)); } else { ErrorViewModel model = new ErrorViewModel { Message = response.Data.ToString() }; return(View("Error", model)); } }
public IActionResult Index() { ResponseDetails response = _apiHelper.SendApiRequest("", "parkinglot/get-all", HttpMethod.Get); List <ParkingLotViewModel> lots = JsonConvert.DeserializeObject <List <ParkingLotViewModel> > (response.Data.ToString()); List <ParkingLotViewModel> model = new List <ParkingLotViewModel> (); for (int i = 0; i < lots.Count; i++) { if (lots[i].IsAproved) { model.Add(lots[i]); } } _dataProtector.ProtectParkingLotRouteValues(model); return(View(model)); }
public IActionResult Dashboard() { ResponseDetails response = _apiHelper.SendApiRequest("", "parkinglot/get/user/" + _tokenDecoder.UserId, HttpMethod.Get); if (response.Success) { List <ParkingLotViewModel> model = JsonConvert.DeserializeObject <List <ParkingLotViewModel> > (response.Data.ToString()); model = CalculateHourlyRate(model); _dataProtector.ProtectParkingLotRouteValues(model); return(View(model)); } else { ErrorViewModel model = new ErrorViewModel { Message = response.Data.ToString() }; return(View("Error", model)); } }