예제 #1
0
        private void InitMedalStandings()
        {
            List <MedalStandings>     MedalsStanding = new List <MedalStandings>();
            GetPropForSelectedService service        = new GetPropForSelectedService();

            List <string> bufCountries = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date).GroupBy(x => x.Person.Country.Name).Select(g => g.Key).ToList();
            var           OlympRes     = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date);

            if (OlympRes == null)
            {
                return;
            }

            for (int i = 0; i < bufCountries.Count; i++)
            {
                MedalStandings bufMedal = new MedalStandings();

                bufMedal.Country = bufCountries[i];
                bufMedal.Golds   = OlympRes.Where(x => x.Person.Country.Name == bufMedal.Country && x.Place == 1).Count();
                bufMedal.Sereb   = OlympRes.Where(x => x.Person.Country.Name == bufMedal.Country && x.Place == 2).Count();;
                bufMedal.Bronz   = OlympRes.Where(x => x.Person.Country.Name == bufMedal.Country && x.Place == 3).Count();
                bufMedal.All     = bufMedal.Golds + bufMedal.Sereb + bufMedal.Bronz;

                MedalsStanding.Add(bufMedal);
            }
            MedalsStanding.OrderBy(x => x.All);
            MedalStandingsListBox.ItemsSource = MedalsStanding.OrderByDescending(x => x.All);

            for (int i = 0; i < MedalStandingsListBox.Items.Count; i++)
            {
                (MedalStandingsListBox.Items[i] as MedalStandings).Number = i + 1;
            }
        }
예제 #2
0
        private void LoadOlympaidTeamStats(string Team)
        {
            GetPropForSelectedService service   = new GetPropForSelectedService();
            List <TeamStat>           TeamStats = new List <TeamStat>();

            var Res = service.GetOlympsResult()
                      .Where(x => x.Person.Country.Name == Team)
                      .Select(x => new { x.Person, x.Place }).ToList();

            List <string> SportTypes = service.GetOlympsResult().GroupBy(x => x.SportType).Select(x => x.Key.Name).ToList();

            if (Res == null)
            {
                return;
            }

            for (int i = 0; i < Res.Count; i++)
            {
                TeamStat teamStat = new TeamStat();


                teamStat.Sport   = SportTypes[i];
                teamStat.AllName = $"{Res[i].Person.FirstName}" +
                                   $" {Res[i].Person.SecondName} " +
                                   $"{Res[i].Person.ThirdName}";
                teamStat.Place = Res[i].Place;

                TeamStats.Add(teamStat);
            }

            //foreach (var s in Res)
            //{
            //    TeamStat teamStat = new TeamStat();


            //    teamStat.Sport = s.SportType.Name;
            //    teamStat.AllName = $"{s.Person.FirstName}" +
            //        $" {s.Person.SecondName} " +
            //        $"{s.Person.ThirdName}";
            //    teamStat.Place = s.Place;

            //    TeamStats.Add(teamStat);
            //}

            if (TeamStats == null)
            {
                return;
            }

            StatStore_TeamStatsListBox.ItemsSource = TeamStats.OrderByDescending(x => x.Place);

            for (int i = 0; i < StatStore_TeamStatsListBox.Items.Count; i++)
            {
                (StatStore_TeamStatsListBox.Items[i] as TeamStat).Number = i + 1;
            }
        }
예제 #3
0
        private void LoadSportsMedalists(string Sport)
        {
            GetPropForSelectedService service      = new GetPropForSelectedService();
            List <SportMedal>         sportsMedals = new List <SportMedal>();

            var Res = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date && x.SportType.Name == Sport && x.Place == 1).Select(x => x.Person).ToList();

            if (Res == null)
            {
                return;
            }

            foreach (var p in Res)
            {
                SportMedal sportMedal = new SportMedal();

                sportMedal.Country = p.Country.Name;
                sportMedal.AllName = $"{p.FirstName} {p.SecondName} {p.ThirdName}";

                sportsMedals.Add(sportMedal);
            }


            StatStore_SportsMedalistListBox.ItemsSource = sportsMedals.OrderByDescending(x => x.Country);

            for (int i = 0; i < StatStore_SportsMedalistListBox.Items.Count; i++)
            {
                (StatStore_SportsMedalistListBox.Items[i] as SportMedal).Number = i + 1;
            }
        }
예제 #4
0
        private void InitAthleteRecord()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            var bufSports = service.GetOlympsResult().GroupBy(x => x.SportType.Name).Select(x => x.Key).ToList();

            try
            {
                StatStore_RecodHolderComboBOx.ItemsSource  = bufSports;
                StatStore_RecodHolderComboBOx.SelectedItem = bufSports[0];
            }
            catch (Exception)
            {
            }
        }
예제 #5
0
        private void InitTeamStats()
        {
            GetPropForSelectedService service      = new GetPropForSelectedService();
            List <string>             bufCountries = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date).GroupBy(x => x.Person.Country.Name).Select(g => g.Key).ToList();

            try
            {
                StatStore_TeamStatsCountryComboBox.ItemsSource  = bufCountries;
                StatStore_TeamStatsCountryComboBox.SelectedItem = StatStore_TeamStatsCountryComboBox.Items[0];
            }
            catch (Exception)
            {
            }
        }
예제 #6
0
        private void InitCompositionOfOlympTeam()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();

            List <string> countries = service.GetOlympsResult().GroupBy(x => x.Person.Country.Name).Select(x => x.Key).OrderByDescending(x => x.Count()).ToList();

            try
            {
                StatStore_CompositionOfOlympTeamComboBox.ItemsSource  = countries;
                StatStore_CompositionOfOlympTeamComboBox.SelectedItem = countries[0];
            }
            catch (Exception)
            {
            }
        }
예제 #7
0
        private void InitSportsMedalists()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();

            List <string> sports = service.GetOlympsResult().Where(x => x.Olympiad.Date == CurrentOlympaid.Date).GroupBy(x => x.SportType.Name).Select(x => x.Key).ToList();

            try
            {
                StatStore_SportsMedalistComboBox.ItemsSource  = sports;
                StatStore_SportsMedalistComboBox.SelectedItem = StatStore_SportsMedalistComboBox.Items[0];
            }
            catch (Exception)
            {
            }
        }
예제 #8
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            OlympResult newType = new OlympResult();
            GetPropForSelectedService getService = new GetPropForSelectedService();


            newType.OlympID     = getService.GetOlympiads().FirstOrDefault(x => x.Date == (OlympiadComboBox.SelectedItem as Olympiad).Date).ID;
            newType.SportTypeID = getService.GetSportTypes().FirstOrDefault(x => x.Name == (OlympiadComboBox.SelectedItem as SportType).Name).ID;

            newType.PersonID = getService.GetPersons().FirstOrDefault(x => x.FirstName == (OlympiadComboBox.SelectedItem as Person).FirstName &&
                                                                      x.SecondName == (OlympiadComboBox.SelectedItem as Person).SecondName &&
                                                                      x.ThirdName == (OlympiadComboBox.SelectedItem as Person).ThirdName).ID;

            newType.Place = Convert.ToInt32(PlaceTextBox.Text);


            foreach (var or in getService.GetOlympsResult())
            {
                if (or.Olympiad.Date == newType.Olympiad.Date)
                {
                    if (or.SportType.Name == newType.SportType.Name)
                    {
                        //if(or.City.Name == newType.City.Name)
                        if (or.Person.FirstName == newType.Person.FirstName)
                        {
                            if (or.Person.SecondName == newType.Person.SecondName)
                            {
                                if (or.Person.ThirdName == newType.Person.ThirdName)
                                {
                                    if (or.Place == newType.Place)
                                    {
                                        MessageBox.Show("This node alredy exist.");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            AddingService addService = new AddingService();

            addService.AddOlympiadResultNode(newType);
            MessageBox.Show("New result node adding.");
        }
예제 #9
0
        private void LoadCompositionOfOlympTeam(string Team)
        {
            GetPropForSelectedService service   = new GetPropForSelectedService();
            List <TeamStat>           TeamStats = new List <TeamStat>();

            var Res = service.GetOlympsResult().Where(x => x.Person.Country.Name == Team).GroupBy(x => new
            {
                x.Person,
                x.Person.Country,
                x.SportType
            }).ToList();

            CompositionOfOlympTeamWindow window =
                new CompositionOfOlympTeamWindow(Team, Res.Select(x => x.Key.Person).ToList(), Res.Select(x => x.Key.SportType).ToList());

            window.ShowDialog();
        }
예제 #10
0
        private void LoadAthleteRecordHolder(string Sport)
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            Person Res = service.GetOlympsResult().Where(x => x.SportType.Name == Sport && x.Place == 1).Select(x => x.Person).First();

            string Holder;

            if (Res == null)
            {
                Holder = "None";
                StatStore_RecodHolderTextBlock.Text = Holder;
                return;
            }

            Holder = $"{Res.FirstName} {Res.SecondName} {Res.ThirdName}";
            StatStore_RecodHolderTextBlock.Text = Holder;
        }
예제 #11
0
        private void InitHostestOfOlymps()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            //var count = service.GetOlympsResult().GroupBy(x => x.Person.Country).Select(group => new
            //{
            //    Name = group.Key,
            //    Count = group.Count()
            //}).OrderByDescending(x => x.Count).Select(x => x.Count).ToList();

            //var count = service.GetOlympsResult().GroupBy(x => x.Person.Country).Select(group => new
            //{
            //    Count = group.Count()
            //}).Select(x => x.Count);

            var country = service.GetOlympsResult().GroupBy(x => x.Person.Country.Name).OrderByDescending(x => x.Count()).First();

            StatStore_ThemeMostHostTextBlock.Text = country.Key;
        }
예제 #12
0
        private void OlympResultInit()
        {
            GetPropForSelectedService service = new GetPropForSelectedService();
            var Results = service.GetOlympsResult();

            List <OlympResultNodeTemplate> ResultsData = new List <OlympResultNodeTemplate>();

            foreach (var r in Results)
            {
                OlympResultNodeTemplate node = new OlympResultNodeTemplate();

                node.OlympiadName  = $"{r.Olympiad.Type.Name} olympiad in {r.Olympiad.Country.Name} {String.Format("{0:y}", r.Olympiad.Date)}";
                node.PersonName    = $"{r.Person.FirstName} {r.Person.SecondName} {r.Person.ThirdName}";
                node.SportTypeName = r.SportType.Name;
                node.Place         = r.Place;

                ResultsData.Add(node);
            }

            OlympResultDataGrid.ItemsSource = ResultsData;
        }