コード例 #1
0
 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));
     }
 }
コード例 #2
0
        public IActionResult Delete([FromRoute] int id)
        {
            RetornoBackEnd retorno = this._servico.Excluir(id);

            return(this.RetornarHttpBackEnd(retorno));
        }
コード例 #3
0
        public IActionResult Put([FromRoute] int id, [FromBody] Anuncio anuncio)
        {
            RetornoBackEnd retorno = this._servico.Atualizar(anuncio);

            return(this.RetornarHttpBackEnd(retorno));
        }
コード例 #4
0
        public IActionResult Post([FromBody] Anuncio anuncio)
        {
            RetornoBackEnd retorno = this._servico.Adicionar(anuncio);

            return(this.RetornarHttpBackEnd(retorno, 201));
        }
コード例 #5
0
        public IActionResult Get(int id)
        {
            RetornoBackEnd retorno = this._servico.LocalizarPorId(id);

            return(this.RetornarHttpBackEnd(retorno));
        }
コード例 #6
0
        public IActionResult Get()
        {
            RetornoBackEnd retorno = this._servico.RetornarTodos();

            return(this.RetornarHttpBackEnd(retorno));
        }