예제 #1
0
        public void AddDivision(SeasonDivision division)
        {
            division.Season = this;

            if (division.GetTeamsThatBelongToDivision() != null)
            {
                division.GetTeamsThatBelongToDivision().ToList().ForEach(t =>
                {
                    if (Teams.Where(team => team.Parent.Id == t.Parent.Id).FirstOrDefault() == null)
                    {
                        AddTeam(t);
                    }
                });
            }

            if (Divisions.Where(d => d.Name.Equals(division.Name)).FirstOrDefault() == null)
            {
                Divisions.Add(division);

                division.Children.ToList().ForEach(cd =>
                {
                    AddDivision(cd);
                });
            }
            else
            {
                //throw new SeasonException("Division was already added. " + division.Name);
            }
        }
예제 #2
0
        internal void Add(string name, int parentId)
        {
            int id = DivisionSQL.Add(name, parentId);

            Divisions.Add(new Division {
                Id = id, Name = name, ParentId = parentId
            });
        }
예제 #3
0
        private async Task LoadDivisions()
        {
            var list = await Proxy.GetAllDivisions();

            foreach (var item in list)
            {
                Divisions.Add(item);
            }
        }
예제 #4
0
        ///////////////////////////////////////////loadDataIntoCombo///////////////////////////////////////////
        //Koen
        public void insertDivisionIntoComboBox()
        {
            var divisions = _dataservice.getAllDivisions();

            Divisions.Clear();
            foreach (var division in divisions)
            {
                Divisions.Add(division);
            }
        }
예제 #5
0
        public void Handle(ParticipantGameCompleted e)
        {
            var divisionName = SimplifyDivision(e.Division);
            var year         = "2014";

            if (MatchYearLookup.ContainsKey(e.Id))
            {
                year = MatchYearLookup[e.Id];
            }

            var division = Divisions.SingleOrDefault(x => x.Name == divisionName && x.Year == year);

            if (division == null)
            {
                division = new Division
                {
                    Name = divisionName,
                    Year = year
                };

                Divisions.Add(division);
            }

            var participant = division.Participants.SingleOrDefault(x => x.ParticipantId == e.ParticipantId);

            if (participant == null)
            {
                participant = new Participant
                {
                    ParticipantId = e.ParticipantId,
                    Scores        = new List <Score>()
                };
                division.Participants.Add(participant);
            }

            participant.Scores.RemoveAll(x => x.MatchId == e.Id);
            participant.Name   = e.Name;
            participant.Gender = e.Gender;
            participant.Scores.Add(new Score {
                MatchId = e.Id, Scratch = e.Score, Wins = e.IsPOA
                    ? (e.POA > e.OpponentPOA ? 1M : e.POA < e.OpponentPOA ? 0M : .5M)
                    : (e.Score > e.OpponentScore ? 1M : e.Score < e.OpponentScore ? 0M : .5M),
            });

            participant.Total   = participant.Scores.Sum(x => x.Scratch);
            participant.Wins    = participant.Scores.Sum(x => x.Wins);
            participant.Average = 1.0M * participant.Total / participant.Scores.Count;
        }
예제 #6
0
        public void Handle(ParticipantGameCompleted e)
        {
            var divisionName = SimplifyDivision(e.Division);
            var year         = "2014";

            if (Matches.ContainsKey(e.Id))
            {
                year = Matches[e.Id];
            }

            var division = Divisions.SingleOrDefault(x => x.Name == divisionName && x.Year == year);

            if (division == null)
            {
                division = new Division
                {
                    Name = divisionName,
                    Year = year
                };

                Divisions.Add(division);
            }

            division.Scores.RemoveAll(x => x.MatchId == e.Id && x.ParticipantId == e.ParticipantId);

            if (divisionName.Equals("Tournament", StringComparison.OrdinalIgnoreCase) && e.Score < 275)
            {
                return;
            }
            if (!divisionName.Equals("Tournament", StringComparison.OrdinalIgnoreCase) && e.POA < 75)
            {
                return;
            }

            division.Scores.Add(new Score
            {
                Gender        = e.Gender,
                MatchId       = e.Id,
                Name          = e.Name,
                ParticipantId = e.ParticipantId,
                POA           = e.POA,
                Scratch       = e.Score,
                Year          = year
            });
        }
예제 #7
0
        private async void ButtonAddDivision_Click(object sender, RoutedEventArgs e)
        {
            var dialog       = new DivisionDialog(DivisionInfos, ProcessTemplates);
            var dialogResult = await dialog.ShowAsync();

            var division = dialog.Division;

            if (dialogResult == ContentDialogResult.Primary && division != null)
            {
                var divisionId = await Proxy.UpsertDivision(division);

                if (divisionId > 0)
                {
                    division.DivisionId = divisionId;
                    Divisions.Add(division);
                }
            }
        }
예제 #8
0
        public static bool ParseFromArgs(string[] args)
        {
            if (!args.Any())
            {
                ShowHelp = true;
            }

            try
            {
                var rem = OptionSet.Parse(args);

                if (!Divisions.Any())
                {
                    Divisions.Add(new List <int> {
                        4
                    });
                }

                if (rem.Any())
                {
                    throw new OptionException();
                }
            }
            catch (Exception ex) when(ex is OptionException || ex is InvalidOperationException)
            {
                Console.WriteLine("Invalid Arguments.");
                PrintHelp();
                Environment.Exit(1);
            }

            if (ShowHelp)
            {
                PrintHelp();
                return(false);
            }

            return(true);
        }