Esempio n. 1
0
        public IActionResult Delete(int id)
        {
            var stage = _repo.GetByID(id);

            Image.Delete(_hostingEnvironment, "stages", stage.Image);
            _repo.Delete(id);
            return(RedirectToAction("List"));
        }
Esempio n. 2
0
 // DELETE: api/Stage/5
 public IHttpActionResult Delete(int id)
 {
     if (_stageRepository.Get(id) == null)
     {
         return(NotFound());
     }
     _stageRepository.Delete(id);
     return(Ok());
 }
Esempio n. 3
0
        public ActionResult Delete(int id)
        {
            if (id > 0)
            {
                sr.Delete(id);
                return(Ok("Stage deleted"));
            }

            return(NotFound("Stage not found"));
        }
Esempio n. 4
0
        public bool Delete(int id)
        {
            try
            {
                var stageDto = GetById(id);
                if (stageDto == null)
                {
                    _logger.LogError($"Stage with id: {id}, hasn't been found in db.");
                    return(false);
                }

                Stage stage = _mapper.Map <Stage>(stageDto);

                _repository.Delete(stage);
                _repository.Save();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside DeleteStage action: {ex.Message}");
                throw new Exception();
            }
        }