示例#1
0
 public int Salvar(Comanda comanda)
 {
     try
     {
         int retorno = Insucesso;
         if (_comandaBO.VerificaSeExisteComanda(comanda) == NaoExiste)
         {
             _banco.Entry(comanda).State = EntityState.Added;
             retorno = _banco.SaveChanges() == Sucesso ? Sucesso : Insucesso.ErroCustomForTernary("Não foi possível cadastrar a comanda, verifique os dados.");
         }
         return(retorno);
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }
 public int Salvar(Cliente cliente)
 {
     try
     {
         InstanciarClienteBO();
         int retorno = Insucesso;
         if (_clienteBO.VerificarSeJaExisteNoSalvamento(cliente) == NaoExiste)
         {
             _banco.Entry(cliente).State = EntityState.Added;
             retorno = _banco.SaveChanges() == Sucesso ? Sucesso : Insucesso.ErroCustomForTernary("Não foi possível salvar o cliente");
         }
         return(retorno);
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }
 public int Salvar(Produto produto)
 {
     try
     {
         InstanciarDbContext();
         InstanciarProdutoBO();
         int retorno = 0;
         if (_produtoBO.VerificaSeExisteProduto(produto) == NaoExiste)
         {
             _banco.Entry(produto).State = EntityState.Added;
             retorno = _banco.SaveChanges() == Sucesso ? Sucesso : Insucesso.ErroCustomForTernary("Não foi possível salvar, verifiques os dados");
         }
         return(retorno);
     }
     catch (CustomException erro)
     {
         throw new CustomException(erro.Message);
     }
     catch (Exception erro)
     {
         throw new Exception(erro.Message);
     }
 }