Пример #1
0
        public async Task <TreatmentResponse> UpdateAsyncTreatment(int id, TreatmentModel treatment)
        {
            var existingTreatment = await _treatmentRepository.FindByIdAsync(id);

            if (existingTreatment == null)
            {
                return(new TreatmentResponse("Treatment not found"));
            }

            try
            {
                _treatmentRepository.UpdateAsyncTreatment(existingTreatment);
                await _unitOfWork.CompleteAsync();

                return(new TreatmentResponse(existingTreatment));
            }
            catch (Exception ex)
            {
                return(new TreatmentResponse($"An error occured when updating Treatment: {ex.Message}"));
            }
        }