Remove sample 'weather' endpoint

This commit is contained in:
Jonathan Bourdon
2024-07-09 15:24:58 -04:00
parent 349999722b
commit 25ea9b50c7
4 changed files with 0 additions and 61 deletions

View File

@@ -1,25 +0,0 @@
namespace Hutopy.Application.WeatherForecasts.Queries.GetWeatherForecasts;
public record GetWeatherForecastsQuery : IRequest<IEnumerable<WeatherForecast>>;
public class GetWeatherForecastsQueryHandler : IRequestHandler<GetWeatherForecastsQuery, IEnumerable<WeatherForecast>>
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task<IEnumerable<WeatherForecast>> Handle(GetWeatherForecastsQuery request, CancellationToken cancellationToken)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
});
}
}

View File

@@ -1,12 +0,0 @@
namespace Hutopy.Application.WeatherForecasts.Queries.GetWeatherForecasts;
public class WeatherForecast
{
public DateTime Date { get; init; }
public int TemperatureC { get; init; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; init; }
}

View File

@@ -1,18 +0,0 @@
using Hutopy.Application.WeatherForecasts.Queries.GetWeatherForecasts;
namespace Hutopy.Web.Endpoints;
public class WeatherForecasts : EndpointGroupBase
{
public override void Map(WebApplication app)
{
app.MapGroup(this)
.RequireAuthorization()
.MapGet(GetWeatherForecasts);
}
private static async Task<IEnumerable<WeatherForecast>> GetWeatherForecasts(ISender sender)
{
return await sender.Send(new GetWeatherForecastsQuery());
}
}

View File

@@ -38,12 +38,6 @@ Content-Type: application/json
###
# GET WeatherForecast
GET {{base_url}}/api/WeatherForecasts
Authorization: Bearer {{auth_token}}
###
# GET GetMyUser
GET {{base_url}}/api/GetMyUser
Authorization: Bearer {{auth_token}}