public void SolicitarCarona(Colaborador caroneiro) { ValidarOfertante(); ValidarVagasDisponiveis(); caroneiro.ValidarArgumentoNulo(); if (EstaBloqueado()) { throw new CaronaBloqueadaException(); } if (caroneiro.EstaBloqueado()) { throw new ColaboradorBloqueadoException("Colaborador sem permissão para solicitar carona."); } if (caroneiro.Equals(Ofertante)) { throw new OfertanteComoCaroneiroException("Não é permitido o próprio ofertante ocupar vaga na própria carona."); } if (ExisteCaroneiro(caroneiro)) { throw new CaroneiroJaInclusoNaCaronaException(); } caroneiro.Validar(); Caroneiros.Add(new CaronaCaroneiro(this, caroneiro)); }
public void ValidarOfertante(Colaborador ofertante = null) { const string Msg = "Colaborador sem permissão para oferecer carona."; ofertante = (ofertante != null) ? ofertante : Ofertante; ofertante.ValidarArgumentoNulo(MSG_OFERTANTE_NAO_INFORMADO); if (ofertante.EstaBloqueado()) { throw new ColaboradorBloqueadoException(Msg); } }