Beispiel #1
0
        public IActionResult Delete(Guid Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var therapist = _therapistRepository.GetById(Id);

            if (therapist == null)
            {
                return(NotFound("Wrong id."));
            }

            _therapistRepository.Delete(Id);
            return(Ok("Therapist deleted."));
        }
        public async Task <IActionResult> Delete(Guid id)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList();
                return(BadRequest(errors));
            }

            var therapist = await _therapistRepository.GetById(id).ConfigureAwait(false);

            if (therapist == null)
            {
                return(NotFound($"There was no therapist with ID {id}."));
            }

            int result = await _therapistRepository.Delete(id).ConfigureAwait(false);

            if (result == 1)
            {
                return(Ok("Therapist deleted."));
            }

            return(StatusCode(500, "There was a problem trying to delete therapist."));
        }