/// <summary>
        /// Get a list of responses that are within the radius of a point. The size of the radius is the primary radius of the action plan
        /// </summary>
        /// <param name="responseGeolocationObj">ResponseGeolocationModel</param>
        /// <returns>List of Response Model</returns>
        public async Task <IEnumerable <ResponseModel> > GetResponsesFromPointRadius(ResponseGeolocationModel responseGeolocationObj)
        {
            if (responseGeolocationObj == null || responseGeolocationObj.EventClusterGeolocationPointLocation == null)
            {
                return(new List <ResponseModel>());
            }

            IEnumerable <ResponseDAO> responseObjs = await _repoResponses.GetItemsAsync(p => p.EndDate.Value == null);

            if (responseObjs == null)
            {
                return(null);
            }

            List <ResponseDAO>   output = new List <ResponseDAO>();
            GeolocationDAOObject daoGeocodeCenterPoint = _mapper.Map <GeolocationDAOObject>(responseGeolocationObj.EventClusterGeolocationPointLocation);

            foreach (var response in responseObjs)
            {
                if (RadiusHelper.IsWithinRadius(daoGeocodeCenterPoint, response.Geolocation, response.ActionPlan.PrimaryRadius))
                {
                    output.Add(response);
                }
            }
            return(_mapper.Map <IEnumerable <ResponseModel> >(output));
        }
示例#2
0
        public async Task <IEnumerable <ResponseModel> > GetResponsesFromPointRadius(ResponseGeolocationModel responseGeolocationObj)
        {
            RestRequest request = await PrepareQuery("Responses/Radius", Method.POST);

            request.AddParameter("application/json", JsonConvert.SerializeObject(responseGeolocationObj), ParameterType.RequestBody);
            var queryResult = await _client.ExecuteTaskAsync <IEnumerable <ResponseModel> >(request);

            if (queryResult.IsSuccessful)
            {
                return(queryResult.Data);
            }
            else
            {
                _logger.LogError($"GetResponsesFromPointRadius: Error: {queryResult.StatusCode}");
            }
            return(null);
        }
        public async Task <IActionResult> GetResponsesFromPointRadius([FromBody] ResponseGeolocationModel responseGeolocationObj)
        {
            IEnumerable <ResponseModel> responseObjs = await _responseDataManager.GetResponsesFromPointRadius(responseGeolocationObj);

            return(Ok(responseObjs));
        }