using Domain.Entities;
using Features.Breweries.Dtos;
using Features.Breweries.Repository;
using MediatR;
namespace Features.Breweries.Queries.GetAllBreweryLocations;
/// Handles by retrieving all located brewery posts.
public class GetAllBreweryLocationsHandler(IBreweryRepository repository)
: IRequestHandler>
{
/// Retrieves every brewery post that has a set location.
public async Task> Handle(
GetAllBreweryLocationsQuery request,
CancellationToken cancellationToken
)
{
IEnumerable breweries = await repository.GetAllLocations();
return breweries.Select(b => b.ToSimplifiedDto());
}
}