public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } int randomSpeed = random.Next(-20, 375); Location location = LocationRepo.GetLocation(LocationId); try { _speedMeasurementRepo.AddSpeedMeasurement(randomSpeed, location, MockData.RandomImage); } catch (CalibrationException cex) { CreateOtionsList(); InfoText = $"Error. The camera must be calibrated contact the support department or try again! {cex.Message}"; return(Page()); } catch (ArgumentException aex) { CreateOtionsList(); InfoText = $"Error. The camera must be calibrated contact the support department or try again! {aex.Message}"; return(Page()); } catch (Exception ex) { InfoText = $"Error. Something went wrong!Contact the support department {ex.Message}"; CreateOtionsList(); return(Page()); } return(RedirectToPage("Index")); }