Beispiel #1
0
        public async Task <ActionResult> CreateOrUpdate(double lat, double lng)
        {
            var          regionId = $"{Math.Truncate(lat * 10)/10}_{Math.Truncate(lng*10)/10}";
            LocationRule rule     = await _locationRulesLogic.GetLocationRuleOrDefaultAsync(regionId, lat, lng);

            EditLocationRuleModel editModel = CreateEditModelFromLocationRule(rule);

            if (string.IsNullOrWhiteSpace(rule.RuleId))
            {
                editModel.IsCreateRequest = true;
            }
            else
            {
                editModel.IsCreateRequest = false;
            }

            return(View("EditLocationRuleProperties", editModel));
        }
        // <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));
        }