finalizare 1.0
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
|
||||
namespace Application.Endpoints.Doctors.QuerriesDoctors;
|
||||
|
||||
public class QuerriesDoctorsHandler(IDoctorRepository database)
|
||||
{
|
||||
public async Task<BaseResponse> HandleGet(Guid id, CancellationToken token)
|
||||
{
|
||||
var doctor = await database.GetByIdAsync(id, token);
|
||||
if (doctor != null)
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = $"Retrieved doctor with id: {id}",
|
||||
Data = doctor
|
||||
};
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = $"Doctor with id: {id} not found",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> HandleGetAll(CancellationToken token)
|
||||
{
|
||||
var doctors = await database.GetAllAsync(token);
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Retrieved doctors",
|
||||
Data = doctors.ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user