示例#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));
        }
示例#2
0
        public async Task <ActionResult> DeleteLocation(LocationPropertiesModel locationProperties)
        {
            if (locationProperties.Latitude != null && locationProperties.Longitude != null)
            {
                await _locationJerkLogic.DeleteLocationJerkAsync(locationProperties.Latitude, locationProperties.Longitude);
            }

            locationProperties         = new LocationPropertiesModel();
            locationProperties.FromMap = false;
            return(View("Index", locationProperties));
        }
示例#3
0
        public ActionResult Index(double?latitude, double?longitude)
        {
            LocationPropertiesModel model = new LocationPropertiesModel();

            if (latitude != null && longitude != null)
            {
                model.FromMap   = true;
                model.Latitude  = latitude;
                model.Longitude = longitude;
                return(View(model));
            }

            model.FromMap = false;
            return(View(model));
        }
示例#4
0
        private LocationPropertiesModel CreateViewModelFromLocationJerk(LocationJerkModelExtended locationJerkModel)
        {
            LocationPropertiesModel model = new LocationPropertiesModel();

            model.JsonList    = JsonConvert.SerializeObject(locationJerkModel.DeviceList);
            model.NoOfDevices = locationJerkModel.NoOfDevices;
            model.Latitude    = locationJerkModel.Latitude;
            model.Longitude   = locationJerkModel.Longitude;
            model.Altitude    = locationJerkModel.Altitude;

            //if (locationJerkModel.Latitude != null)
            //{
            //    model.Latitude = locationJerkModel.Latitude.ToString();
            //}

            //if (locationJerkModel.Longitude != null)
            //{
            //    model.Longitude = locationJerkModel.Longitude.ToString();
            //}

            //if (locationJerkModel.Altitude != null)
            //{
            //    model.Altitude = locationJerkModel.Altitude.ToString();
            //}

            switch (locationJerkModel.Status)
            {
            case LocationStatus.Critical:
                model.Status = "Road Condition Critical.";
                break;

            case LocationStatus.Caution:
                model.Status = "Bad Road, proceed with Caution.";
                break;

            default:
                model.Status = "Road Fixed";
                break;
            }

            return(model);
        }
示例#5
0
        public async Task <ActionResult> DeleteSelected(IEnumerable <LocationReferenceModel> locations)
        {
            if (locations != null)
            {
                try
                {
                    IEnumerable <LocationModel> locationBatch = GetLocationModelListFromReference(locations);

                    await _locationJerkLogic.DeleteLocationsInBatchAsync(locationBatch);
                }
                catch (Exception ex)
                {
                }
            }

            LocationPropertiesModel locationProperties = new LocationPropertiesModel();

            locationProperties.FromMap = false;
            return(View("Index", locationProperties));
        }
示例#6
0
        // <summary>
        /// Navigate to the LocationReport screen
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>

        public async Task <ActionResult> LocationReport(LocationPropertiesModel locationProperties)
        {
            var errorMessage = locationProperties.CheckForErrorMessage();

            if (!String.IsNullOrWhiteSpace(errorMessage))
            {
                return(Json(new { error = errorMessage }));
            }

            var regionLatitude  = Math.Truncate((double)locationProperties.Latitude * 100) / 100;
            var regionLongitude = Math.Truncate((double)locationProperties.Longitude * 100) / 100;
            var regionId        = $"{Math.Truncate(regionLatitude * 10)/10}_{Math.Truncate(regionLongitude * 10)/10}";

            LocationRule rule = await _locationRulesLogic.GetLocationRuleOrDefaultAsync(regionId, regionLatitude, regionLongitude);

            locationProperties.RuleId                 = rule.RuleId;
            locationProperties.RegionLatitude         = rule.RegionLatitude;
            locationProperties.RegionLongitude        = rule.RegionLongitude;
            locationProperties.JerkedDeviceSelectList = GetSelectListFromJsonList(locationProperties.JsonList);
            return(View("LocationReport", locationProperties));
        }