public IActionResult UploadImage(ParkingImageModel model) { if (ModelState.IsValid) { string base64EncodedImage = ImageProcessing.ProcessIFormFile(model.Image); UploadLotImageModel dataModel = new UploadLotImageModel { Image = base64EncodedImage, ImageName = model.Image.FileName, ParkingLotId = model.ParkingLotId }; ResponseDetails response = _apiHelper.SendApiRequest(dataModel, "parkingLot/upload-image", HttpMethod.Post); if (response.Success) { return(RedirectToAction("Images", new { id = _dataProtector.Protect(model.ParkingLotId) })); } else { ErrorViewModel errorModel = new ErrorViewModel { Message = response.Data.ToString() }; return(View("Error", errorModel)); } } ModelState.AddModelError("", "Validation Error."); return(View(model)); }
public IActionResult Images(string id) { int newId = _dataProtector.Unprotect(id); ResponseDetails response = _apiHelper.SendApiRequest("", "parkingLot/all-images/" + newId, HttpMethod.Get); if (response.Success) { List <string> model = JsonConvert.DeserializeObject <List <string> > (response.Data.ToString()); ParkingImageModel ImageModel = new ParkingImageModel() { ParkingLotId = newId, Images = model }; return(View(ImageModel)); } else { ErrorViewModel model = new ErrorViewModel { Message = response.Data.ToString() }; return(View("Error", model)); } }