コード例 #1
0
 public int Deletar(Produto produto)
 {
     try
     {
         InstanciarDbContext();
         InstanciarProdutoBO();
         int retorno = 0;
         if (_produtoBO.VerificarSeEstaNaComanda(produto) == NaoExiste)
         {
             if (_produtoBO.VerificarSeEstaNaMovimentacao(produto) == NaoExiste)
             {
                 _banco.Entry(produto).State = EntityState.Deleted;
                 retorno = _banco.SaveChanges() == Sucesso ? Sucesso : Insucesso;
             }
         }
         return(retorno);
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }