Skip to content

Instantly share code, notes, and snippets.

@umayeras
Last active November 12, 2021 10:51
Show Gist options
  • Save umayeras/48d33d7e0d7e2c004a05be277ba27b06 to your computer and use it in GitHub Desktop.
Save umayeras/48d33d7e0d7e2c004a05be277ba27b06 to your computer and use it in GitHub Desktop.
public class GetSampleByIdHandler : IRequestHandler<GetSampleByIdQuery, ServiceResponse>
{
private readonly IReadOnlyRepository<Sample> repository;
public GetSampleByIdHandler(IReadOnlyRepository<Sample> repository)
{
this.repository = repository;
}
public async Task<ServiceDataResponse> Handle(GetSampleByIdQuery request, CancellationToken cancellationToken)
{
var sample = await repository.GetSingleAsync(x => x.Id == request.Id);
return ServiceDataResponse.Ok(sample);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment