Controller.Repositorio.ClienteRepositorio.Salvar C# (CSharp) 메소드

Salvar() 공개 메소드

public Salvar ( Cliente cliente ) : int
cliente Model.Entidades.Cliente
리턴 int
        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);
            }


        }