Esempio n. 1
0
        public IActionResult Delete(int trailId)
        {
            if (!_trailRepository.ExsistsById(trailId))
            {
                return(NotFound());
            }
            Trail trail = (Trail)_trailRepository.GetById(trailId);

            if (!_trailRepository.Delete(trail))
            {
                ModelState.AddModelError("", $"Something went wrong deleting the record {trail}");
                return(StatusCode(500, ModelState));
            }
            return(NoContent());
        }
Esempio n. 2
0
        public IActionResult DeleteTrail(int trailId)
        {
            //FLOW: if park does not exist return notfound(404)
            if (!_trailRepo.TrailExists(trailId))
            {
                return(NotFound());
            }
            var trailObj = _trailRepo.GetTrail(trailId);

            if (!_trailRepo.Delete(trailObj))
            {
                ModelState.AddModelError("", $"Something went wrong when deleting the record {trailObj.Name}");
                return(StatusCode(500, ModelState));
            }
            //FLOW: Not returning any content after httpdelete
            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> DeleteTrail(int trailId)
        {
            try
            {
                var deletedTrail = await repository.Delete(trailId);

                return(Ok(deletedTrail));
            }
            catch (ArgumentNullException e)
            {
                var paramName = e.ParamName;

                if (paramName != null)
                {
                    return(NotFound(paramName));
                }

                throw;
            }
        }