예제 #1
0
        public void ClearTeams()
        {
            lock (UndoActions)
            {
                UndoActions.Add(
                    new ChGKCommand
                {
                    OnApply = () =>
                    {
                        _service.RemoveAllTeams();

                        _gaService.ReportEvent(GACategory.DealWithTeams, GAAction.Click, "all teams removed");
                    },
                    OnUndo = () =>
                    {
                        LoadTeams();
                    },
                });

                Teams = new List <TeamViewModel>();
            }

            UndoBarMetaData = new UndoBarMetadata {
                Text = StringResources.TeamsRemoved
            };
        }
예제 #2
0
        void RemoveTeam(object parameter)
        {
            lock (UndoActions)
            {
                var position     = ((int[])parameter)[0];
                var teamToDelete = Teams[position];

                UndoActions.Add(
                    new ChGKCommand
                {
                    OnApply = () =>
                    {
                        _service.RemoveTeam(teamToDelete.ID);

                        _gaService.ReportEvent(GACategory.DealWithTeams, GAAction.Click, "team removed");
                    },
                    OnUndo = () =>
                    {
                        Teams.Insert(position, teamToDelete);
                        Teams = Teams.Where(_ => true).ToList();
                    },
                });

                Teams = Teams.Where((m, i) => i != position).ToList();
            }

            UndoBarMetaData = new UndoBarMetadata {
                Text = StringResources.TeamRemoved
            };
        }
예제 #3
0
        public void ClearResults()
        {
            lock (UndoActions)
            {
                var oldTeamScores = Teams.Select(team => team.Score).ToList();

                UndoActions.Add(
                    new ChGKCommand
                {
                    OnApply = () =>
                    {
                        _service.CleanResults();

                        _gaService.ReportEvent(GACategory.DealWithTeams, GAAction.Click, "results cleaned");
                    },
                    OnUndo = () =>
                    {
                        Teams = Teams.Where((team, i) =>
                        {
                            try
                            {
                                team.Score = oldTeamScores[i];
                            } catch  {
                            };

                            return(true);
                        }).ToList();
                    },
                });

                Teams = Teams.Where(team =>
                {
                    team.Score = 0;
                    return(true);
                }).ToList();
            }

            UndoBarMetaData = new UndoBarMetadata {
                Text = StringResources.ScoreRemoved
            };
        }