Created
December 15, 2018 14:56
-
-
Save zeptobook/8db3b0f6091f2a86bb2b3b2c59260926 to your computer and use it in GitHub Desktop.
SampleDataController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
namespace zeptoapp.Controllers | |
{ | |
[Route("api/[controller]")] | |
public class SampleDataController : Controller | |
{ | |
private static string[] Summaries = new[] | |
{ | |
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | |
}; | |
[HttpGet("[action]")] | |
public IEnumerable<WeatherForecast> WeatherForecasts() | |
{ | |
var rng = new Random(); | |
return Enumerable.Range(1, 5).Select(index => new WeatherForecast | |
{ | |
DateFormatted = DateTime.Now.AddDays(index).ToString("d"), | |
TemperatureC = rng.Next(-20, 55), | |
Summary = Summaries[rng.Next(Summaries.Length)] | |
}); | |
} | |
public class WeatherForecast | |
{ | |
public string DateFormatted { get; set; } | |
public int TemperatureC { get; set; } | |
public string Summary { get; set; } | |
public int TemperatureF | |
{ | |
get | |
{ | |
return 32 + (int)(TemperatureC / 0.5556); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment