mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 01:54:43 +00:00
Enforce brewery ownership on update and delete (#267)
This commit is contained in:
@@ -7,10 +7,10 @@ namespace Features.Breweries.Queries.GetAllBreweryLocations;
|
||||
|
||||
/// <summary>Handles <see cref="GetAllBreweryLocationsQuery" /> by retrieving all located brewery posts.</summary>
|
||||
public class GetAllBreweryLocationsHandler(IBreweryRepository repository)
|
||||
: IRequestHandler<GetAllBreweryLocationsQuery, IEnumerable<SimplifiedBreweryDto>>
|
||||
: IRequestHandler<GetAllBreweryLocationsQuery, IEnumerable<BreweryWithLocationDto>>
|
||||
{
|
||||
/// <summary>Retrieves every brewery post that has a set location.</summary>
|
||||
public async Task<IEnumerable<SimplifiedBreweryDto>> Handle(
|
||||
public async Task<IEnumerable<BreweryWithLocationDto>> Handle(
|
||||
GetAllBreweryLocationsQuery request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
|
||||
@@ -7,4 +7,4 @@ namespace Features.Breweries.Queries.GetAllBreweryLocations;
|
||||
/// Retrieves all brewery posts that have a set location. Bound directly from
|
||||
/// <c>GET /api/brewery/locations</c>.
|
||||
/// </summary>
|
||||
public record GetAllBreweryLocationsQuery : IRequest<IEnumerable<SimplifiedBreweryDto>>;
|
||||
public record GetAllBreweryLocationsQuery : IRequest<IEnumerable<BreweryWithLocationDto>>;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GetBreweryByIdHandler(IBreweryRepository repository)
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
BreweryPost? brewery = await repository.GetByIdAsync(request.BreweryPostId);
|
||||
BreweryPost? brewery = await repository.GetByIdAsync(request.BreweryPostId, cancellationToken);
|
||||
return brewery?.ToDto();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace Features.Breweries.Queries.GetBreweryLocationsWithinRange;
|
||||
/// Handles <see cref="GetBreweryLocationsWithinRangeQuery" /> by retrieving nearby located brewery posts.
|
||||
/// </summary>
|
||||
public class GetBreweryLocationsWithinRangeHandler(IBreweryRepository repository)
|
||||
: IRequestHandler<GetBreweryLocationsWithinRangeQuery, IEnumerable<SimplifiedBreweryDto>>
|
||||
: IRequestHandler<GetBreweryLocationsWithinRangeQuery, IEnumerable<BreweryWithLocationDto>>
|
||||
{
|
||||
/// <summary>Retrieves brewery posts within range of the requested coordinates, nearest first.</summary>
|
||||
public async Task<IEnumerable<SimplifiedBreweryDto>> Handle(
|
||||
public async Task<IEnumerable<BreweryWithLocationDto>> Handle(
|
||||
GetBreweryLocationsWithinRangeQuery request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
|
||||
@@ -12,4 +12,4 @@ namespace Features.Breweries.Queries.GetBreweryLocationsWithinRange;
|
||||
/// <param name="Longitude">The origin longitude, in decimal degrees.</param>
|
||||
/// <param name="RangeInMetres">The maximum distance, in metres, from the origin coordinates.</param>
|
||||
public record GetBreweryLocationsWithinRangeQuery(double Latitude, double Longitude, double RangeInMetres)
|
||||
: IRequest<IEnumerable<SimplifiedBreweryDto>>;
|
||||
: IRequest<IEnumerable<BreweryWithLocationDto>>;
|
||||
|
||||
Reference in New Issue
Block a user