コード例 #1
0
        public IActionResult Detail(string id, string FahOrCalc)
        {
            WeatherList weatherList = new WeatherList();

            weatherList.park        = dao.ParkDetail(id);
            weatherList.weatherList = WeatherDao.GetWeather(id);
            weatherList.FahOrCalc   = GetTempChoice();


            return(View(weatherList));
        }
コード例 #2
0
        public async Task <ActionResult <IEnumerable <WeatherForecast> > > Get()
        {
            IEnumerable <WeatherForecast> data = await _weatherService.GetWeather();

            if (data == null)
            {
                return(NotFound());
            }

            return(Ok(data));
        }
        private async Task <WeatherDataReply> GetWeatherData(WeatherRequest request)
        {
            var split     = request.Location.Split(",");
            var latitude  = split[0];
            var longitude = split[1];

            var temp = await _weather.GetWeather(latitude, longitude);

            var record = new WeatherDataReply
            {
                Temperature   = temp,
                Location      = request.Location,
                Windspeed     = 0,
                Winddirection = 0
            };

            return(record);
        }
コード例 #4
0
        public IActionResult Index(string city)
        {
            //check city !=null
            if (String.IsNullOrEmpty(city))
            {
                return(View());
            }

            var weather = _weather.GetWeather(city);

            if (ReferenceEquals(weather, null))
            {
                return(View());
            }
            else
            {
                return(View(weather));  //return 2 models
            }
        }
コード例 #5
0
        public async Task <IActionResult> GetWeather(double Lon, double Lat)
        {
            var result = await weatherAPI.GetWeather(new GeographicalCoordinates(Lon, Lat));

            return(Json(result));
        }