Exemplo n.º 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));
        }
Exemplo n.º 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));
        }