示例#1
0
        public void RemoverTipoPagamento(TiposPagamentoColaborador tipoPagamento)
        {
            if (tipoPagamento == null)
            {
                throw new ArgumentNullException(nameof(tipoPagamento));
            }
            if (!ExisteTipoPagamento(tipoPagamento.Id))
            {
                throw new DomainException($"Tipo de pagamento {tipoPagamento.TipoPagamento?.Descricao} não está atribuído ao colaborador {Nome}.");
            }
            var tipoPagamentoDB = _tiposPagamento.FirstOrDefault(t => t.Id == tipoPagamento.Id);

            _tiposPagamento.Remove(tipoPagamentoDB);
        }
示例#2
0
        public void AtribuirTipoPagamento(TiposPagamentoColaborador tipoPagamento)
        {
            if (tipoPagamento == null)
            {
                throw new ArgumentNullException(nameof(tipoPagamento));
            }

            if (tipoPagamento.ColaboradorId != Id)
            {
                throw new DomainException($"Tipo de pagamento {tipoPagamento.TipoPagamento?.Descricao} não está vinculado ao colaborador {Nome}.");
            }

            if (ExisteTipoPagamento(tipoPagamento.Id))
            {
                throw new DomainException($"Tipo de pagamento {tipoPagamento.TipoPagamento?.Descricao} já foi atribuído ao colaborador {Nome}.");
            }
            _tiposPagamento.Add(tipoPagamento);
        }