Files
the-biergarten-app/web/backend/Features/Features.Breweries/Queries/GetAllBreweryLocations/GetAllBreweryLocationsHandler.cs
2026-09-05 14:34:23 -04:00

26 lines
844 B
C#

using Domain.Entities;
using Features.Breweries.Dtos;
using Features.Breweries.Repository;
using MediatR;
namespace Features.Breweries.Queries.GetAllBreweryLocations;
/// <summary>
/// Handles queries for brewery posts with locations.
/// </summary>
public class GetAllBreweryLocationsHandler(IBreweryRepository repository)
: IRequestHandler<GetAllBreweryLocationsQuery, IEnumerable<BreweryWithLocationDto>>
{
/// <summary>
/// Retrieves and maps every brewery post that has a location.
/// </summary>
public async Task<IEnumerable<BreweryWithLocationDto>> Handle(
GetAllBreweryLocationsQuery request,
CancellationToken cancellationToken
)
{
IEnumerable<BreweryPost> breweries = await repository.GetAllLocations();
return breweries.Select(b => b.ToSimplifiedDto());
}
}