示例#1
0
        /// <summary>
        /// Removes the participant.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="participant">The participant.</param>
        private void RemoveParticipant <T>(T participant)
        {
            if (participant != null)
            {
                if (participant is Player)
                {
                    var player = participant as Player;

                    if (Players != null && Players.Contains(player))
                    {
                        Players.Remove(player);
                    }
                }
                else if (participant is Referee)
                {
                    var referee = participant as Referee;

                    if (Referees != null && Referees.Contains(referee))
                    {
                        Referees.Remove(referee);
                    }
                }
                else if (participant is GameMaster)
                {
                    GameMaster = null;
                }
            }
        }
示例#2
0
        public override global::System.Data.DataSet Clone()
        {
            Referees cln = ((Referees)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
        public void RefereesList()
        {
            Referee  r        = new Referee("daniel", "kaminski");
            Referees referees = new Referees();

            referees.AddRef(r);
            Assert.AreEqual(new List <Referee>(), referees.getRefs());
        }
示例#4
0
 // This method will add a Game Master if one doesn't excist, or replace the existing one.
 public void AddGameMaster(Referee referee)
 {
     if (Referees.Contains(referee))
     {
         GameMaster = referee;
     }
     else
     {
         Console.WriteLine("This referee does not excist in the tournament, and can therefore not be set as Game Master");
     }
 }
示例#5
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            Referees ds = new Referees();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
        private void SearchBoxTextChanged(object sender, TextChangedEventArgs e)
        {
            if (e.Text.ToString() == "")
            {
                ActualReferees = Referees;
            }
            else
            {
                ActualReferees = Referees.Where(p => p.Name.ToLower().Contains(e.Text.ToString().ToLower()));
            }

            adapter.Swap(ActualReferees.ToList());
        }
示例#7
0
        public void Simulate(bool doubles)
        {
            if (!TeamCount.Contains(Teams.Count))
            {
                Console.WriteLine($"There is not an allowed number of teams in the tournament. Current amount: {Teams.Count}");
                return;
            }
            if (!Referees.Any())
            {
                Console.WriteLine("Please add at least one referee to the tournament");
                return;
            }
            if (GameMaster == null)
            {
                Console.WriteLine("A Game Master has not been set.");
                return;
            }

            var currentMatches = new List <Match>();
            var currentTeams   = doubles ? Teams.Where(team => team.IsDouble).ToList() : Teams.Where(team => !team.IsDouble).ToList();
            var round          = 1;

            while (currentTeams.Count > 1)
            {
                var initializedMatches = InitializeMatches(currentTeams);
                Matches.AddRange(initializedMatches);
                currentMatches.AddRange(initializedMatches);
                currentTeams.Clear();
                foreach (var match in currentMatches)
                {
                    match.Play(round);
                    currentTeams.Add(match.Winner);
                }
                currentMatches.Clear();
                round++;
            }

            Winner.Add(currentTeams[0]);
        }
        private async void BtnSaveReferee_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                Referees referee = new Referees
                {
                    FirstName  = TxtFirstName.Text,
                    LastName   = TxtLastName.Text,
                    MiddleName = TxtMiddleName.Text,
                    CityId     = int.Parse(CmbCities.SelectedValue.ToString()),
                    Id         = Id ?? 0
                };

                if (string.IsNullOrEmpty(TxtMiddleName.Text))
                {
                    referee.MiddleName = "N/A";
                }
                else
                {
                    referee.MiddleName = TxtMiddleName.Text;
                }

                if (Id.HasValue)
                {
                    await _aPIServiceReferee.Update <Referees>(referee, referee.Id.ToString());

                    MessageBox.Show("Referee updated", "Information");
                }
                else
                {
                    await _aPIServiceReferee.Insert <Referees>(referee);

                    MessageBox.Show("Referee added", "Information");
                }
                Close();
            }
        }
示例#9
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                Referees ds = new Referees();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "RefereesDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
示例#10
0
        static void Main(string[] args)
        {
            #region (Тут первое)
            Console.WriteLine("\n1.Количество нападающих по странам\n");
            var attakersInCountry = from p in Players
                                    where p.Position == "Forward"
                                    group p by p.Country into k
                                    select new
            {
                Country = k.Key,
                Count   = k.Count()
            };


            foreach (var item in attakersInCountry)
            {
                Console.WriteLine($"Country = {item.Country} , Количество футбольщиков = {item.Count}");
            }
            var attackersInCountry2 = Players
                                      .Where(p => p.Position == "Forward")
                                      .GroupBy(p => p.Country)
                                      .Select(p => new { Country = p.Key, Count = p.Count() })
                                      .ToList();

            foreach (var item in attackersInCountry2)
            {
                Console.WriteLine($"Country = {item.Country} , Количество футбольщиков = {item.Count}");
            }
            #endregion
            #region (Тут второе)
            Console.WriteLine("\n2. Сколько было забито голов на каждом стадионе\n");
            var goalsInStadium = from match in Matches
                                 join stad in Stadiums on match.StadionId equals stad.Id
                                 group match by stad.Name + " - " + stad.City into p
                                 let sum = p.Sum(g => g.GuestTeamGoals + g.HomeTeamGoals)
                                           select new
            {
                Name  = p.Key,
                Count = sum
            };
            foreach (var item in goalsInStadium)
            {
                Console.WriteLine($"{item.Name} - {item.Count}");
            }

            var goalsInStadium1 = Matches
                                  .Join(Stadiums, m => m.StadionId, s => s.Id, (m, s) => new
            {
                s.Name,
                s.City,
                m.GuestTeamGoals,
                m.HomeTeamGoals
            })
                                  .GroupBy(s => s.Name + " - " + s.City)
                                  .Select((s) => new
            {
                Name  = s.Key,
                Count = s.Sum(g => g.GuestTeamGoals + g.HomeTeamGoals)
            }).ToList();
            foreach (var item in goalsInStadium1)
            {
                Console.WriteLine($"{item.Name} - {item.Count}");
            }
            #endregion
            #region (Тут третье)
            Console.WriteLine("\n#3 стадион на котором было забито больше всего голов\n");
            var stadiumGoalsMax = (from match in Matches
                                   join stadiums in Stadiums on match.StadionId equals stadiums.Id
                                   group match by stadiums.Name into allgoals
                                   let goal = allgoals.Sum(g => (g.GuestTeamGoals + g.HomeTeamGoals))
                                              orderby goal
                                              select new
            {
                name = allgoals.Key,
                maxGoal = goal
            }).ToList().Last();

            Console.WriteLine($"Максимальное количество голов: {stadiumGoalsMax}");


            var stadiumGoalsMax1 = Matches
                                   .Join(Stadiums, m => m.StadionId, s => s.Id, (m, s) => new
            {
                s.Name,
                m.GuestTeamGoals,
                m.HomeTeamGoals
            })
                                   .GroupBy(m => m.Name)
                                   .Select((ma) => new
            {
                Name     = ma.Key,
                MaxCount = ma.Sum(g => g.GuestTeamGoals + g.HomeTeamGoals)
            }).
                                   OrderBy(m => m.MaxCount).
                                   ToList().
                                   Last();
            Console.WriteLine(stadiumGoalsMax1);
            #endregion
            #region (Тут четвертое)
            Console.WriteLine("\n4.Вывести всех людей относящихся к команде вместе с их должностями.\n");

            var playersInTeams = (from player in Players
                                  select new
            {
                player.FirstName,
                player.LastName,
                Position = "Игрок - " + player.Position,
                player.TeamId
            }).ToList();

            var workerNew = (from w in Workers
                             select new
            {
                w.FirstName,
                w.LastName,
                Position = "Работник - " + w.Position,
                w.TeamId
            }).ToList();

            foreach (var worker in workerNew)
            {
                playersInTeams.Add(worker);
            }

            var teamsAndPlayers = from player in playersInTeams
                                  join team in Teams on player.TeamId equals team.Id
                                  select new
            {
                Team = team.Title,
                player.TeamId,
                player.FirstName,
                player.LastName,
                player.Position
            } into playerInTeams
            group playerInTeams by playerInTeams.TeamId into grouppedPlayers
                select new
            {
                Team    = grouppedPlayers.ToList()[0].Team,
                Players = (from p in grouppedPlayers
                           select new
                {
                    p.FirstName,
                    p.LastName,
                    p.Position
                }).ToList()
            };
            foreach (var item in teamsAndPlayers)
            {
                Console.WriteLine($"{item.Team} ");
                foreach (var person in item.Players)
                {
                    Console.WriteLine($"\t{person.FirstName} {person.LastName} Позиция: {person.Position}");
                }
            }

            var NewPlayers = (Players
                              .Select(p => new
            {
                p.FirstName,
                p.LastName,
                Position = "Игрок - " + p.Position,
                p.TeamId
            })).ToList();

            var NewWorkers = (Workers
                              .Select(w => new
            {
                w.FirstName,
                w.LastName,
                Position = "Работник - " + w.Position,
                w.TeamId
            }).Union(NewPlayers)).ToList();



            var teamToList = (NewWorkers
                              .Join(Teams, allteam => allteam.TeamId, team => team.Id,
                                    (allteam, team) => new
            {
                Team = team.Title,
                allteam.TeamId,
                allteam.FirstName,
                allteam.LastName,
                allteam.Position
            })
                              .GroupBy(grouppedPlayers => grouppedPlayers.TeamId)
                              .Select(grouppedPlayers => new
            {
                Key = grouppedPlayers.ToList()[0].Team,
                PlayersWorkers = (from players in grouppedPlayers
                                  select new
                {
                    players.FirstName,
                    players.LastName,
                    players.Position
                }).ToList()
            })).ToList();

            foreach (var team in teamToList)
            {
                Console.WriteLine($"Команда - {team.Key} \n");
                foreach (var person in team.PlayersWorkers)
                {
                    Console.WriteLine($"Игрок - {person.FirstName} {person.LastName}\n " +
                                      $"Позиция: {person.Position}");
                }
                Console.WriteLine("\n\n");
            }


            #endregion
            #region (тут пятое)
            Console.WriteLine("\n5.Судьи и их матчи, в формате группировки\n");
            var matches = (from match in Matches
                           join guestTeam in Teams on match.GuestTeamId equals guestTeam.Id
                           join homeTeam in Teams on match.HomeTeamId equals homeTeam.Id
                           join stadium in Stadiums on match.StadionId equals stadium.Id
                           select new
            {
                MatchId = match.Id,
                MatchDate = match.MatchDate,
                Stadium = stadium.Name,
                HomeTeam = homeTeam.Title,
                GuestTeam = guestTeam.Title,
            }).ToList();

            var matchAndRefree = (from matchAndRef in MatchesAndReferees
                                  join referee in Referees on matchAndRef.RefereeId equals referee.Id
                                  join match in matches on matchAndRef.MatchId equals match.MatchId
                                  select new
            {
                Referee = referee.FirstName + " " + referee.LastName,
                Match = match
            }).ToList();

            var groupedMatchesAndRefrees = (from matchAndRef in matchAndRefree
                                            group matchAndRef.Match by matchAndRef.Referee);

            foreach (var item in groupedMatchesAndRefrees)
            {
                Console.WriteLine("\nСудья - " + item.Key + "\n");
                foreach (var match in item)
                {
                    Console.WriteLine($"Матч: {match.MatchId}\n" +
                                      $"Время матча: {match.MatchDate}\n" +
                                      $"Стадион: {match.Stadium}\n" +
                                      $"Домашиняя команда: {match.HomeTeam}\n" +
                                      $"Гостевая команда: {match.GuestTeam}\n");
                }
            }
            var matches2 = Matches
                           .Join(Teams, m => m.GuestTeamId, t => t.Id, (m, t) => new
            {
                m.Id,
                GuestTeam = t.Title,
                m.HomeTeamId,
                m.IsFinished,
                m.MatchDate,
                m.StadionId
            }).Join(Teams, m => m.HomeTeamId, t => t.Id, (m, t) => new
            {
                m.Id,
                m.GuestTeam,
                HomeTeam = t.Id,
                m.IsFinished,
                m.MatchDate,
                m.StadionId
            }).Join(Stadiums, m => m.StadionId, s => s.Id, (m, s) => new
            {
                m.Id,
                m.GuestTeam,
                m.HomeTeam,
                m.IsFinished,
                m.MatchDate,
                Stadium = s.Name
            });
            var referee2 = Referees
                           .Join(MatchesAndReferees, r => r.Id, m => m.RefereeId, (r, m) => new
            {
                Referee = r.FirstName + " " + r.LastName,
                m.MatchId
            }).Join(matches2, r => r.MatchId, m => m.Id, (r, m) => new
            {
                Referee   = r.Referee,
                ID        = m.Id,
                LIVE      = m.IsFinished,
                Date      = m.MatchDate,
                Stadium   = m.Stadium,
                HomeTeam  = m.HomeTeam,
                GuestTeam = m.GuestTeam
            }).GroupBy(m => m.Referee);

            foreach (var item in referee2)
            {
                Console.WriteLine("\nСудья - " + item.Key + "\n");
                foreach (var match in item)
                {
                    Console.WriteLine($"Матч: {match.ID}\n" +
                                      $"Время матча: {match.Date}\n" +
                                      $"Стадион: {match.Stadium}\n" +
                                      $"Домашиняя команда: {match.HomeTeam}\n" +
                                      $"Гостевая команда: {match.GuestTeam}\n");
                }
            }

            #endregion
            #region (тут шестое)
            Console.WriteLine("\n6.Сгруппировать игроков по командам и их позициям позициям\n");
            var playerByTeamsAndPos = (from player in Players
                                       join team in Teams on player.TeamId equals team.Id
                                       group player by team.Title into playerByTitle
                                       select new
            {
                TeamTitle = playerByTitle.Key,
                Player = (from player in playerByTitle
                          select new
                {
                    PlayerName = player.LastName + " " + player.FirstName,
                    Position = player.Position
                }
                          into playerByTeamTitle
                          group playerByTeamTitle.PlayerName by playerByTeamTitle.Position)
            }).ToList();

            foreach (var team in playerByTeamsAndPos)
            {
                Console.WriteLine("Команда: " + team.TeamTitle + "\n");
                foreach (var pos in team.Player)
                {
                    Console.WriteLine("\tПозиция: " + pos.Key);
                    foreach (var player in pos)
                    {
                        Console.WriteLine("\t\t " + player + "\n");
                    }
                }
            }

            var teamPositionPlayers = Players
                                      .Join(Teams, p => p.TeamId, t => t.Id, (p, t) => new
            {
                Team          = t.Title,
                PlayerAndTeam = p
            })
                                      .GroupBy(playerItTeams => playerItTeams.Team)
                                      .Select(playerItTeams => new
            {
                playerItTeams.Key,
                Grouping = playerItTeams.ToList().GroupBy(playerItTeams => playerItTeams.PlayerAndTeam.Position)
            }).ToList();
            foreach (var team in teamPositionPlayers)
            {
                Console.WriteLine("Команда: " + team.Key);
                foreach (var position in team.Grouping)
                {
                    Console.WriteLine("\tПозиция: " + position.Key);
                    foreach (var player in position)
                    {
                        Console.WriteLine($"\t\t {player.PlayerAndTeam.FirstName} {player.PlayerAndTeam.LastName}");
                    }
                }
                Console.WriteLine();
            }
            #endregion
        }
示例#11
0
 public void RemoveReferee(Referee referee)
 {
     Referees.Remove(referee);
 }
示例#12
0
 public void AddReferees(List <Referee> referees)
 {
     Referees.AddRange(referees);
 }
示例#13
0
 public void AddReferees(Referee referee)
 {
     Referees.Add(referee);
 }