Example #1
0
        public AppFront.FrontData GetWeatherById(string param)
        {
            long id;

            AppFront.FrontData data = new AppFront.FrontData();
            if (!long.TryParse(param, out id))
            {
                data.Code = AppFront.ReturnCode.BAD;
                return(data);
            }
            var resp = handler.GetWeather(id);

            if (resp == null)
            {
                data.Code = AppFront.ReturnCode.BAD;
                return(data);
            }
            data.City           = resp.Name;
            data.Country        = resp.Sys.Country;
            data.Humidity       = resp.Main.Humidity;
            data.Temperature    = resp.Main.Temp;
            data.TemperatureMin = resp.Main.TempMin;
            data.TemperatureMax = resp.Main.TempMax;
            data.Pressure       = resp.Main.Pressure;
            data.Weather        = resp.Weather[0].Main;
            data.Code           = AppFront.ReturnCode.GOOD;
            return(data);
        }
Example #2
0
        public AppFront.FrontData GetWeatherByGeo(string param)
        {
            AppFront.FrontData data = new AppFront.FrontData();
            string[]           strs = param.Split(',');
            if (strs.Length < 2)
            {
                data.Code = AppFront.ReturnCode.BAD;
                return(data);
            }
            string lat  = strs[0].Trim();
            string lon  = strs[1].Trim();
            var    resp = handler.GetWeather(lat, lon);

            if (resp == null)
            {
                data.Code = AppFront.ReturnCode.BAD;
                return(data);
            }
            data.City           = resp.Name;
            data.Country        = resp.Sys.Country;
            data.Humidity       = resp.Main.Humidity;
            data.Temperature    = resp.Main.Temp;
            data.TemperatureMin = resp.Main.TempMin;
            data.TemperatureMax = resp.Main.TempMax;
            data.Pressure       = resp.Main.Pressure;
            data.Weather        = resp.Weather[0].Main;
            data.Code           = AppFront.ReturnCode.GOOD;
            return(data);
        }