16 lines
695 B
C#
16 lines
695 B
C#
namespace DocuMed.Repository.Handlers.Hospitals;
|
|
|
|
public class GetHospitalQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetHospitalQuery, HospitalSDto>
|
|
{
|
|
public async Task<HospitalSDto> Handle(GetHospitalQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var response = await repositoryWrapper.SetRepository<Hospital>()
|
|
.TableNoTracking
|
|
.Where(h => h.Id == request.Id)
|
|
.Select(HospitalMapper.ProjectToSDto)
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
if (response == null)
|
|
throw new BaseApiException(ApiResultStatusCode.NotFound, "Hospital not found");
|
|
return response;
|
|
}
|
|
} |