public async Task <Result <HaartProphylaxisResponse> > Handle(HaartProphylaxisCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { HaartProphylaxisService _service = new HaartProphylaxisService(_unitOfWork); try { List <PatientDrugAdministration> patientDrugAdministion_data = new List <PatientDrugAdministration>(); // List<PatientChronicIllness> patientChronicIllnesses_data = new List<PatientChronicIllness>(); List <PreventiveService> preventiveServices_data = new List <PreventiveService>(); // int result1= await _service.AddPatientChronicIllness(request.PatientChronicIllnesses); int result2 = await _service.AddPatientDrugAdministration(request.PatientDrugAdministration); // int result3= await _service.AddPreventiveService(request.preventiveServices); if (result2 > 0) { result = 1; } return(Result <HaartProphylaxisResponse> .Valid(new HaartProphylaxisResponse() { PreventivePartnerId = result })); } catch (Exception e) { Log.Error(e.Message); throw e; } } }
public async Task <IActionResult> Post([FromBody] HaartProphylaxisCommand serviceCommand) { var response = await _mediator.Send(new HaartProphylaxisCommand { PatientDrugAdministration = serviceCommand.PatientDrugAdministration, PatientChronicIllnesses = serviceCommand.PatientChronicIllnesses, OtherIllness = serviceCommand.OtherIllness }, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }