Beispiel #1
0
        public async Task <IActionResult> DeleteSpecialist(int id)
        {
            var specialist = await repository.GetSpecialistToDelete(id);

            if (specialist == null)
            {
                return(NotFound());
            }

            repository.Remove(specialist);
            await unitOfWork.CompleteAsync();

            return(Ok(id));
        }
        public async Task <SpecialistResponse> DeleteAsync(int id)
        {
            var existingSpecialist = await _specialistRepository.FindById(id);

            if (existingSpecialist == null)
            {
                return(new SpecialistResponse("Specialist not found"));
            }

            try
            {
                _specialistRepository.Remove(existingSpecialist);
                await _unitOfWork.CompleteAsync();

                return(new SpecialistResponse(existingSpecialist));
            }
            catch (Exception ex)
            {
                return(new SpecialistResponse($"An error ocurred while deleting specialist: {ex.Message}"));
            }
        }