示例#1
0
        public ActionResult GetThreeMonthTemperature(string city, int firstMonth, int year)
        {
            DateTime date = DateTime.Parse(string.Format("01.{0}.{1}", firstMonth.ToString("d2"), year)).AddMonths(1);

            Dictionary <string, DayTemperature> dict = new Dictionary <string, DayTemperature>();


            foreach (DayTemperature dt in DayTemperature.GetThreeMonthTemperature(city, date.Month, date.Year))
            {
                dict[dt.date.ToString("yyyy-MM-dd")] = dt;
            }
            string threeMonthWeather        = JsonConvert.SerializeObject(dict);
            string threeMonthWeatherForCity = "{\"" + city + "\":" + threeMonthWeather + "}";

            return(Content(threeMonthWeatherForCity));
        }