/// <summary> /// Handles the incoming rest requests /// </summary> /// <param name="boundVariables"> The bound variables. </param> /// <param name="operationInput"> The operation input. </param> /// <param name="outputFormat"> The output format. </param> /// <param name="requestProperties"> The request properties. </param> /// <param name="responseProperties"> The response properties. </param> /// <returns> </returns> /// <exception cref="System.ArgumentNullException"></exception> public static byte[] Handler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; var errors = new ErrorModel(400); object[] geometryJson; var found = operationInput.TryGetArray("geometry", out geometryJson); if (!found || geometryJson.Length < 1) errors.Message += "Value cannot be null: {0}. ".With("geometry"); double? durationThreshold; found = operationInput.TryGetAsDouble("durationThreshold", out durationThreshold); if (!found || !durationThreshold.HasValue) durationThreshold = 0; if (errors.HasErrors) return Json(new ErrorContainer(errors)); var areaOfInterest = new AreaOfInterest { PointCollection = geometryJson.Cast<decimal>().ToList() }; IPolygon4 polygon; try { polygon = CommandExecutor.ExecuteCommand(new BuildPolygonFromPointsCommand(areaOfInterest)); } catch (Exception ex) { errors.Message += ex.Message; return Json(new ErrorContainer(errors)); } SolarPotential solarValues = null; try { solarValues = CommandExecutor.ExecuteCommand(new GetSolarPotentialCommand(polygon, ApplicationCache.PropertyValueIndexMap, durationThreshold.GetValueOrDefault(0))); } catch (Exception ex) { errors.Message += ex.Message; } return Json(new SolarContainer(solarValues)); }
/// <summary> /// Initializes a new instance of the <see cref="ErrorContainer" /> class. /// </summary> /// <param name="error"> The error. </param> public ErrorContainer(ErrorModel error) { Error = error; }