Skip to content

Instantly share code, notes, and snippets.

@ekaraman89
Last active July 19, 2022 18:36
Show Gist options
  • Save ekaraman89/f9c78608838b0e3751f6dd01716a9225 to your computer and use it in GitHub Desktop.
Save ekaraman89/f9c78608838b0e3751f6dd01716a9225 to your computer and use it in GitHub Desktop.
[HttpGet(Name = "GetWeatherForecast")]
public IActionResult Get()
{
try
{
IEnumerable<WeatherForecast> list = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
if (list != null)
{
throw new ApplicationException();
}
return Ok(list);
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
return BadRequest(ex.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment