public void delete(DeletePatientRequest request) { try { var response = new DeletePatientResponse(); var bc = new PatientComponent(); bc.Delete(request.Id); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public override async Task <ActionResult <DeletePatientResponse> > HandleAsync([FromRoute] DeletePatientRequest request, CancellationToken cancellationToken) { var response = new DeletePatientResponse(request.CorrelationId()); var spec = new ClientByIdIncludePatientsSpec(request.ClientId); var client = await _repository.GetBySpecAsync(spec); if (client == null) { return(NotFound()); } var patientToDelete = client.Patients.FirstOrDefault(p => p.Id == request.PatientId); client.Patients.Remove(patientToDelete); await _repository.UpdateAsync(client); return(Ok(response)); }