示例#1
0
        public IActionResult Manage(string id)
        {
            int newId = _dataProtector.Unprotect(id);

            ResponseDetails response = _apiHelper.SendApiRequest("", "slot/parkinglot/" + newId, HttpMethod.Get);

            if (response.Success)
            {
                List <SlotViewModel> model = JsonConvert.DeserializeObject <List <SlotViewModel> > (response.Data.ToString());

                PopulateHelperProperties(model);
                _dataProtector.ProtectSlotRouteValues(model);

                ResponseDetails slotTypeResponse = _apiHelper.SendApiRequest("", "slot-type/get-all", HttpMethod.Get);

                ManageSlotModel slotModel = new ManageSlotModel
                {
                    Slots     = model,
                    SlotTypes = JsonConvert.DeserializeObject <List <SlotTypeViewModel> > (slotTypeResponse.Data.ToString())
                };

                return(View(slotModel));
            }
            else
            {
                ErrorViewModel model = new ErrorViewModel
                {
                    Message = response.Data.ToString()
                };

                return(View("Error", model));
            }
        }
示例#2
0
        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));
            }
        }