Beispiel #1
0
        public bool FixtureGenerado(DateTime fechaInicio, string deporte, string tipo)
        {
            if (!CampoValido(deporte) || !CampoValido(tipo) || (tipo != "Liga" && tipo != "Grupos"))
            {
                throw new EncuentroDataException();
            }
            Deporte deporteActual = _deportesRepository.ObtenerDeportePorNombre(deporte);

            if (deporteActual == null)
            {
                throw new NoExisteDeporteException();
            }
            if (deporteActual.EsIndividual)
            {
                throw new TipoDeFixtureIncompatibleException();
            }
            List <Participante> participantes = _participantesRepository.ObtenerParticipantesPorDeporte(deporte);

            if (participantes == null || participantes.Count == 1 || participantes.Count == 0)
            {
                throw new NoExistenParticipantesException();
            }
            Fixture          fixture    = GenerarFixture(fechaInicio, tipo, participantes);
            List <Encuentro> encuentros = fixture.GenerarFixture();
            bool             generado   = true;

            foreach (Encuentro encuentro in encuentros)
            {
                if (ExisteEncuentroParticipante(encuentro.FechaHora, participantes))
                {
                    generado = false;
                }
                break;
            }
            foreach (Encuentro encuentro in encuentros)
            {
                if (ExisteEcuentroMismoDiaParaParticipantes(encuentro))
                {
                    throw new ExisteEncuentroMismoDiaException();
                }
            }

            if (generado)
            {
                foreach (Encuentro encuentro in encuentros)
                {
                    encuentro.Deporte = deporteActual;
                    _encuentrosRepository.Insert(encuentro);
                    _unitOfWork.Save();
                }
            }
            return(generado);
        }
Beispiel #2
0
 public IEnumerable <Participante> ObtenerParticipantesPorDeporte(string deporte)
 {
     return(_participantesRepository.ObtenerParticipantesPorDeporte(deporte));
 }