public override async Task <ActionResult <UpdatePatientResponse> > HandleAsync(UpdatePatientRequest request, CancellationToken cancellationToken) { var response = new UpdatePatientResponse(request.CorrelationId); var spec = new ClientByIdIncludePatientsSpec(request.ClientId); var client = await _repository.GetBySpecAsync(spec); if (client == null) { return(NotFound()); } var patientToUpdate = client.Patients.FirstOrDefault(p => p.Id == request.PatientId); if (patientToUpdate == null) { return(NotFound()); } patientToUpdate.Name = request.Name; await _repository.UpdateAsync(client); var dto = _mapper.Map <PatientDto>(patientToUpdate); response.Patient = dto; return(Ok(response)); }
public void delete(UpdatePatientRequest request) { try { var response = new UpdatePatientResponse(); var bc = new PatientComponent(); bc.Update(request.Patient); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }