public IActionResult Delete(int id) { var stage = _repo.GetByID(id); Image.Delete(_hostingEnvironment, "stages", stage.Image); _repo.Delete(id); return(RedirectToAction("List")); }
// DELETE: api/Stage/5 public IHttpActionResult Delete(int id) { if (_stageRepository.Get(id) == null) { return(NotFound()); } _stageRepository.Delete(id); return(Ok()); }
public ActionResult Delete(int id) { if (id > 0) { sr.Delete(id); return(Ok("Stage deleted")); } return(NotFound("Stage not found")); }
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(); } }