private IActionResult RetornarHttpBackEnd(RetornoBackEnd retorno, int CodigoHttp = 0) { if (retorno.sucesso) { if (CodigoHttp == 0) { return(Ok(retorno.conteudo)); } else { return(StatusCode(CodigoHttp, retorno.conteudo)); } } else { return(BadRequest(retorno.conteudo)); } }
public IActionResult Delete([FromRoute] int id) { RetornoBackEnd retorno = this._servico.Excluir(id); return(this.RetornarHttpBackEnd(retorno)); }
public IActionResult Put([FromRoute] int id, [FromBody] Anuncio anuncio) { RetornoBackEnd retorno = this._servico.Atualizar(anuncio); return(this.RetornarHttpBackEnd(retorno)); }
public IActionResult Post([FromBody] Anuncio anuncio) { RetornoBackEnd retorno = this._servico.Adicionar(anuncio); return(this.RetornarHttpBackEnd(retorno, 201)); }
public IActionResult Get(int id) { RetornoBackEnd retorno = this._servico.LocalizarPorId(id); return(this.RetornarHttpBackEnd(retorno)); }
public IActionResult Get() { RetornoBackEnd retorno = this._servico.RetornarTodos(); return(this.RetornarHttpBackEnd(retorno)); }