예제 #1
0
        public IActionResult Forecasts(int days = 3, string format = "json")
        {
            var user = HttpContext.User;
            var q    = new WeatherService().GetForecasts("721943", "c");

            if (format == "xml")
            {
                return(Content(ForecastsXmlFormatter.Serialize(q), "text/xml"));
            }
            return(Json(q));
        }
예제 #2
0
        public IActionResult Weather(int days = 3, string format = "json")
        {
            // Consider using MediaTypeNames constants to avoid magic strings like "json" or "xml".

            var q = new WeatherService().GetForecasts("721943", "c", days);

            if (format == "xml")
            {
                return(Content(
                           ForecastsXmlFormatter.Serialize(q),
                           "text/xml"));
            }
            return(Json(q));
        }