public async Task <DiagnosisResponse> UpdateAsync(int id, Diagnosis diagnosis) { var existingDiagnosis = await _diagnosisRepository.FindByIdAsync(id); if (existingDiagnosis == null) { return(new DiagnosisResponse("Diagnosis not found.")); } existingDiagnosis.Name = diagnosis.Name; try { _diagnosisRepository.Update(existingDiagnosis); await _unitOfWork.CompleteAsync(); return(new DiagnosisResponse(existingDiagnosis)); } catch (Exception ex) { // Do some logging stuff return(new DiagnosisResponse($"An error occurred when updating the diagnosis: {ex.Message}")); } }
public IActionResult UpdateDiagnosis([FromBody] Diagnosis model) { dia_repo.Update(model); return(new OkObjectResult(new { DiagnosisID = model.DiagnosisId })); }