Example #1
0
        public override async Task <ActionResult <ListPatientResponse> > HandleAsync([FromQuery] ListPatientRequest request, CancellationToken cancellationToken)
        {
            var response = new ListPatientResponse(request.CorrelationId());

            var spec   = new ClientByIdIncludePatientsSpecification(request.ClientId);
            var client = await _repository.GetAsync <Client, int>(spec);

            if (client == null)
            {
                return(NotFound());
            }

            response.Patients = _mapper.Map <List <PatientDto> >(client.Patients);
            response.Count    = response.Patients.Count;

            return(Ok(response));
        }
Example #2
0
        public override async Task <ActionResult <ListPatientResponse> > HandleAsync([FromRoute] ListPatientRequest request,
                                                                                     CancellationToken cancellationToken)
        {
            var response = new ListPatientResponse(request.CorrelationId());

            var spec   = new ClientByIdIncludePatientsSpecification(request.ClientId);
            var client = await _repository.GetBySpecAsync(spec);

            if (client == null)
            {
                return(NotFound());
            }

            response.Patients = _mapper.Map <List <PatientDto> >(client.Patients);
            response.Patients.ForEach(p =>
            {
                p.ClientName = client.FullName;
                p.ClientId   = client.Id;
            });
            response.Count = response.Patients.Count;

            return(Ok(response));
        }