public ContaPagarId Insert(ContaPagar entity, bool commit = true)
        {
            var findContaPagar = this.ContaPagarDAO.GetByID(entity.GetId());

            if (findContaPagar != null)
            {
                throw new BusinessException(new { Parcela = "Conta a Pagar já cadastrada." });
            }
            entity.DataBaixa     = null;
            entity.DataPagamento = null;
            entity.UserBaixa     = null;

            entity.UserCancelamento          = null;
            entity.JustificativaCancelamento = null;
            entity.DataCancelamento          = null;

            var id = this.ContaPagarDAO.Insert(entity, commit);

            return(id);
        }
        public void Update(ContaPagar entity, bool commit = true)
        {
            var dbEntity = this.ContaPagarDAO.GetByID(entity.GetId());

            if (dbEntity == null)
            {
                throw new BusinessException(new { Parcela = "Conta a Pagar não cadastrada." });
            }

            if (dbEntity.Valor != entity.Valor)
            {
                throw new BusinessException(new { Valor = "Não pode alterar o valor." });
            }

            if (dbEntity.DataEmissao != entity.DataEmissao)
            {
                throw new BusinessException(new { DataEmissao = "Não pode alterar a data de emissão." });
            }

            this.ContaPagarDAO.Update(entity, commit);
        }