public async Task <Result <PatientIpt> > Handle(EditHeiPatientIptCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { try { PatientIpt patientIpt = _unitOfWork.Repository <PatientIpt>() .Get(x => x.PatientId == request.PatientIpt.PatientId && !x.DeleteFlag).FirstOrDefault(); if (patientIpt != null) { patientIpt.AdheranceMeasurement = request.PatientIpt.AdheranceMeasurement; patientIpt.AdheranceMeasurementAction = request.PatientIpt.AdheranceMeasurementAction; patientIpt.Hepatotoxicity = request.PatientIpt.Hepatotoxicity; patientIpt.IptDateCollected = request.PatientIpt.IptDateCollected; patientIpt.IptDueDate = request.PatientIpt.IptDueDate; } _unitOfWork.Repository <PatientIpt>().Update(patientIpt); await _unitOfWork.SaveAsync(); return(Result <PatientIpt> .Valid(request.PatientIpt)); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); return(Result <PatientIpt> .Invalid(e.Message)); } } }
public async Task <IActionResult> Put([FromBody] EditHeiPatientIptCommand editHeiPatientIptCommand) { var response = await _mediator.Send(editHeiPatientIptCommand, Request.HttpContext.RequestAborted); if (response) { return(Ok(response.Value)); } return(BadRequest(response.Value)); }