using Features.Breweries.Repository; using MediatR; namespace Features.Breweries.Commands.DeleteBrewery; /// /// Processes requests. /// public class DeleteBreweryHandler(IBreweryRepository repository) : IRequestHandler { /// /// Confirms that the caller owns the post before deleting it. /// /// /// Thrown if the brewery post does not exist. /// /// /// Thrown if the caller did not create the brewery post. /// public async Task Handle(DeleteBreweryCommand request, CancellationToken cancellationToken) { await repository.EnsureCallerOwnsBreweryAsync( request.BreweryPostId, request.RequestingUserId, cancellationToken ); await repository.DeleteAsync(request.BreweryPostId); } }