public void AutomaticMatchChampionship(int championshipId, int groupId)
        {
            Random rnd          = new Random();
            int    quantityTeam = 0;
            int    round        = 0;
            int    count        = 0;
            int    turno        = 0;
            int    fieldId      = 0;

            List <int> teamSubscription = new List <int>();

            string[] matchs;


            var championship = _championshipRepository.GetById(championshipId).Result;

            switch (championship.ChampionshipType)
            {
            case ChampionshipType.Grupos:
                if (groupId == 0)
                {
                    throw new Exception();
                }
                else
                {
                    var resultGroupChampionship = _groupChampionshipRepository.GetAll().Result;
                    var groupChampionship       = resultGroupChampionship.Where(p => p.GroupId == (Group)groupId && p.Subscription.ChampionshipId == championshipId).ToList();

                    foreach (var e in groupChampionship)
                    {
                        teamSubscription.Add(e.SubscriptionId);
                        fieldId = e.Subscription.Championship.FieldId;
                    }
                }
                break;

            case ChampionshipType.MataMata:
                break;

            case ChampionshipType.PontosCorridos:
                var result        = _subscriptionRepository.GetAll().Result;
                var subscriptions = result.Where(p => p.ChampionshipId == championshipId);

                foreach (var e in subscriptions)
                {
                    teamSubscription.Add(e.Id);
                    fieldId = e.Championship.FieldId;
                }
                break;

            default:
                break;
            }

            quantityTeam = teamSubscription.Count();

            if (quantityTeam % 2 == 0)
            {
                round = quantityTeam - 1;
            }
            else
            {
                round = quantityTeam;
            }

            if (championship.GoBack)
            {
                turno  = 2;
                matchs = new string[Divers.CalculaFatorial(quantityTeam) / Divers.CalculaFatorial(quantityTeam - 2)];
            }
            else
            {
                turno  = 1;
                matchs = new string[Divers.CalculaFatorial(quantityTeam) / Divers.CalculaFatorial(quantityTeam - 2) / 2];
            }

            count = 0;

            for (int t = 0; t < turno; t++)
            {
                for (int i = 0; i < quantityTeam; i++)
                {     //For para caminhar entre os times
                    for (int j = i; j < quantityTeam; j++)
                    { //For para caminha entre os adversários
                        if (teamSubscription[i] != teamSubscription[j])
                        {
                            MatchChampionship matchChampionship = new MatchChampionship
                            {
                                HomeSubscriptionId  = teamSubscription[i],
                                GuestSubscriptionId = teamSubscription[j],
                                HomePoints          = 0,
                                GuestPoints         = 0,
                                MatchDate           = DateTime.Now,
                                RegisterDate        = DateTime.Now,
                                StartTime           = "",
                                Round = 0
                            };

                            _matchChampionshipRepository.Add(matchChampionship);

                            //Sumula sumula = new Sumula();

                            //sumula.IDPartidaCampeonato = partidaCampeonato.IDPartidaCampeonato;
                            //sumula.sObservacao = "";
                            //sumula.dDataCadastro = DateTime.Now;
                            //db.Sumula.Add(sumula);
                            //db.SaveChanges();
                        }
                    }
                }
            }

            if (quantityTeam % 2 == 0)
            {
                OrdenaRodada(championshipId, teamSubscription);
            }
            else
            {
                List <int> timesInscritosNew = new List <int>();

                foreach (int e in teamSubscription)
                {
                    timesInscritosNew[count] = e;
                    count++;
                }

                timesInscritosNew[teamSubscription.Count()] = 10000000;

                OrdenaRodada(championshipId, timesInscritosNew);
            }
        }