コード例 #1
0
        public async Task <SpecialtyResponse> DeleteAsync(int id)
        {
            var existingSpecialty = await _specialtyRepository.FindById(id);

            if (existingSpecialty == null)
            {
                return(new SpecialtyResponse("Specialty not found"));
            }
            try
            {
                _specialtyRepository.Remove(existingSpecialty);
                await _unitOfWork.CompleteAsync();

                return(new SpecialtyResponse(existingSpecialty));
            }
            catch (Exception ex)
            {
                return(new SpecialtyResponse($"An error ocurred while deleting specialty: {ex.Message}"));
            }
        }