Пример #1
0
        /// <summary>
        /// Generate a new rule with bare-bones configuration. This new rule can then be configured and sent
        /// back through the SaveDeviceRuleAsync method to persist.
        /// </summary>
        /// <param name="regionId"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public async Task <LocationRule> GetNewRuleAsync(string regionId, double latitude, double longitude)
        {
            //making sure we have only 2 decimal places counted
            double regionLatitude  = Math.Truncate(latitude * 100) / 100;
            double regionLongitude = Math.Truncate(longitude * 100) / 100;

            return(await Task.Run(() =>
            {
                var rule = new LocationRule();
                rule.InitializeNewRule(regionId, regionLatitude, regionLongitude);

                return rule;
            }));
        }