Ejemplo n.º 1
0
        public async Task <ActionResult> GetLocationProperties(double?latitude, double?longitude)
        {
            LocationJerkModelExtended location = await _locationJerkLogic.GetLocationDetails(latitude, longitude);

            LocationPropertiesModel locationModel = CreateViewModelFromLocationJerk(location);

            return(PartialView("_LocationProperties", locationModel));
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> GetJerkGraphData(string deviceId, string latitude, string longitude)
        {
            return(await GetServiceResponseAsync <LocationReportGraphPaneDataModel>(async() =>
            {
                double lat;
                double lng;
                LocationReportGraphPaneDataModel dataModel = null;
                if (Double.TryParse(latitude, out lat) && Double.TryParse(longitude, out lng) && !String.IsNullOrEmpty(deviceId))
                {
                    LocationJerkModelExtended locationJerkModel = await _locationJerkLogic.GetLocationDetails(lat as double?, lng as double?);
                    if (locationJerkModel.DeviceList != null)
                    {
                        DeviceJerkModel jerkModel = locationJerkModel.DeviceList.Where(d => d.DeviceId == deviceId).FirstOrDefault();

                        dataModel = new LocationReportGraphPaneDataModel()
                        {
                            DeviceId = jerkModel.DeviceId,
                            Speed = jerkModel.Speed,
                            Heading = jerkModel.Heading
                        };

                        IList <LocationJerkGraphFieldModel> graphFields = ExtractLocationJerkGraphFields();
                        dataModel.LocationJerkGraphFields = graphFields != null ? graphFields.ToArray() : null;

                        IEnumerable <LocationJerkGraphModel> graphModels = GetLocationJerkGraphModels(jerkModel.CapturedJerks);

                        if (graphModels == null)
                        {
                            dataModel.LocationJerkGraphModels = new LocationJerkGraphModel[0];
                        }
                        else
                        {
                            dataModel.LocationJerkGraphModels = graphModels.OrderBy(t => t.Timestamp).ToArray();
                        }
                    }
                }
                return dataModel;
            }, false));
        }