示例#1
0
        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}"));
            }
        }
示例#2
0
 public IActionResult UpdateDiagnosis([FromBody] Diagnosis model)
 {
     dia_repo.Update(model);
     return(new OkObjectResult(new { DiagnosisID = model.DiagnosisId }));
 }