public IActionResult Delete(int id) { try { _restauranteService.Delete(id); return(Ok()); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public async Task <IActionResult> Excluir(RestauranteDTO restaurante) { try { await _restauranteService.Delete(restaurante); return(RedirectToAction("Index", "Restaurante")); } catch (Exception ex) { ViewBag.ErroGenerico = ex.Message; } return(View()); }
public Task <HttpResponseMessage> Excluir(int id) { try { var entidade = _service.Delete(id); Resposta.VerificaRetorno(true, entidade); this._response = Request.CreateResponse(TRespostaHttp.StatusCode, entidade); } catch (Exception ex) { this._response = Request.CreateResponse(HttpStatusCode.BadRequest, ex); } return(CreateResponse(this._response)); }
public IActionResult Delete(int id) { try { var restaurante = _svc.getById(id); if (restaurante == null) { return(NotFound()); } _svc.Delete(restaurante); return(Ok("Deletado com sucesso!")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult Delete(int id) { try { var restaurante = _restauranteService.GetById(id); if (restaurante == null) { return(NotFound()); } _restauranteService.Delete(restaurante); return(Ok("Removido!")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult Delete(int id) { restauranteService.Delete(x => x.Id == id); restauranteService.Save(); return(RedirectToAction("Index")); }