public async Task <BaseResponse <Patient> > Handle(GetListPatientQuery request, CancellationToken cancellationToken) { var response = new BaseResponse <Patient> () { ReponseName = nameof(GetListPatientQuery), Content = new List <Patient> () { } }; var entity = await _patientRepository.GetAllAsync(); entity = _mapper.Map <List <Patient> > (entity); if (entity == null) { response.Status = ResponseType.Error; response.Message = $"{nameof(Patient)} not found."; response.Content = null; } else { response.Status = ResponseType.Success; response.Message = $"{nameof(Patient)} get successfully."; response.Content.AddRange(entity); } return(response); }
public async Task <ActionResult <BaseResponse <Patient> > > GetPatients() { var query = new GetListPatientQuery(); var result = await _mediator.Send(query); return(Ok(result)); }