finalizare 1.0
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using Domain.Entities;
|
||||
|
||||
namespace Application.Endpoints.Appointments.QuerriesAppointments;
|
||||
|
||||
public class QuerriesAppointmentHandler(IAppointmentsMongoDbService appointmentsMongoDbService)
|
||||
{
|
||||
public async Task<BaseResponse> GetByPatientId(Guid patientId, CancellationToken token)
|
||||
{
|
||||
var criteria = new List<(string FieldName, string Value)>
|
||||
{
|
||||
("PatientId", patientId.ToString())
|
||||
};
|
||||
var appointments = await appointmentsMongoDbService.FindAsync<Appointment>(criteria, token);
|
||||
|
||||
if (appointments.Count == 0)
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = $"Appointments not found in system.",
|
||||
Data = null
|
||||
};
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = $"Appointments successfully retrieved.",
|
||||
Data = appointments
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> GetsByDoctorId(Guid doctorId, CancellationToken token)
|
||||
{
|
||||
var criteria = new List<(string FieldName, string Value)>
|
||||
{
|
||||
("DoctorId", doctorId.ToString())
|
||||
};
|
||||
var appointments = await appointmentsMongoDbService.FindAsync<Appointment>(criteria, token);
|
||||
|
||||
if (appointments.Count == 0)
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = $"Appointments not found in system.",
|
||||
Data = null
|
||||
};
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = $"Appointments successfully retrieved.",
|
||||
Data = appointments
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user