public async Task <Prescription?> GetPrescription( Medicine medicine, PrescriptionByIdDataLoader prescriptionById, CancellationToken cancellationToken) { if (medicine.PrescriptionId is null) { return(null); } return(await prescriptionById.LoadAsync(medicine.PrescriptionId.Value, cancellationToken)); }
public async Task <IEnumerable <Prescription?> > GetPrescriptions( [Parent] Doctor doctor, [Service] AppDbContext dbContextFactory, PrescriptionByIdDataLoader prescriptionById, CancellationToken cancellationToken) { int[] prescriptionIds = await dbContextFactory.Prescriptions .Where(x => x.DoctorId == doctor.Id) .Select(s => s.Id) .ToArrayAsync(cancellationToken: cancellationToken); return(await prescriptionById.LoadAsync(prescriptionIds, cancellationToken)); }
public Task <Prescription> GetPrescription (int id, PrescriptionByIdDataLoader prescriptionById, CancellationToken cancellationToken) => prescriptionById.LoadAsync(id, cancellationToken);