示例#1
0
        public async Task <IHttpActionResult> GetLocationsHistory([FromBody] GetLocationHistoryRequest getLocationHistoryRequest)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var geolocationsHistory = await _geolocationRepository.GetGeolocations(UrlHelper.Prepare(getLocationHistoryRequest.IpOrHost),
                                                                                       getLocationHistoryRequest.DateTimeFrom,
                                                                                       getLocationHistoryRequest.DateTimeTo,
                                                                                       getLocationHistoryRequest.StartIndex,
                                                                                       getLocationHistoryRequest.LimitQuery);

                var response = new GetLocationHistoryResponse();
                geolocationsHistory.ForEach(geolocationHistoryModel =>
                                            response.GetLocationHistory.Add(_geolocationService.MapGeolocationModelToResponse(geolocationHistoryModel)));

                return(Ok(response));
            }
            catch (Exception ex)
            {
                _logger.Error("GetLocationsHistory error " + ex.Message, ex);
                return(InternalServerError(new Exception("Check server logs")));
            }
        }
        public GetLocationHistoryResponse GetGeolocationHistory(IList <GeolocationModel> geolocationsList)
        {
            GetLocationHistoryResponse response = new GetLocationHistoryResponse();

            foreach (var geolocation in geolocationsList)
            {
                response.GetLocationHistory.Add(MapGeolocationModelToResponse(geolocation));
            }

            return(response);
        }