public async Task <IActionResult> Get(GetImmunizationHistoryCommand immunizationHistoryCommand) { var response = await _mediator.Send(immunizationHistoryCommand, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }
public async Task <Result <List <Vaccination> > > Handle(GetImmunizationHistoryCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { try { List <Vaccination> vaccine = await _unitOfWork.Repository <Vaccination>() .Get(x => x.PatientId == request.PatientId && x.DeleteFlag == false) .ToListAsync(cancellationToken: cancellationToken); return(Result <List <Vaccination> > .Valid(vaccine)); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); return(Result <List <Vaccination> > .Invalid(e.Message)); } } }