отключил модераторов
All checks were successful
Lint / Run linters (push) Successful in 34s
Build and deploy / Publish image (push) Successful in 38s
Build and deploy / Deploy image (push) Successful in 11s

This commit is contained in:
Sergey Karmanov 2024-06-21 13:26:02 +03:00
parent 67e5d51014
commit 7d4edb6caa

View File

@ -10,7 +10,7 @@ public static class WeatherForecastEndpointsExtensions
{ {
var group = app.MapGroup("weatherforecast"); var group = app.MapGroup("weatherforecast");
group.MapGet(string.Empty, async (WeatherForecastContext db) => await db.Forecasts.ToListAsync()); group.MapGet(string.Empty, async (WeatherForecastContext db) => await db.Forecasts.ToListAsync());
group.MapDelete("{id}", [Authorize(Roles="moderator")]async (WeatherForecastContext db, int id) => group.MapDelete("{id}", [Authorize]async (WeatherForecastContext db, int id) =>
{ {
var forecast = await db.Forecasts.FindAsync(id); var forecast = await db.Forecasts.FindAsync(id);
if (forecast == null) if (forecast == null)
@ -23,14 +23,14 @@ public static class WeatherForecastEndpointsExtensions
return Results.NoContent(); return Results.NoContent();
}); });
group.MapPost(string.Empty, [Authorize(Roles="moderator")] async (WeatherForecastContext db, WeatherForecast forecast) => group.MapPost(string.Empty, [Authorize] async (WeatherForecastContext db, WeatherForecast forecast) =>
{ {
db.Forecasts.Add(forecast); db.Forecasts.Add(forecast);
await db.SaveChangesAsync(); await db.SaveChangesAsync();
return Results.Created($"/weatherforecast/{forecast.Id}", forecast); return Results.Created($"/weatherforecast/{forecast.Id}", forecast);
}); });
group.MapPut("{id}", [Authorize(Roles="moderator")] async (WeatherForecastContext db, int id, WeatherForecast forecast) => group.MapPut("{id}", [Authorize] async (WeatherForecastContext db, int id, WeatherForecast forecast) =>
{ {
if (id != forecast.Id) if (id != forecast.Id)
{ {