Exemplo n.º 1
0
        public void RemovePlayer(IContest contest, IList <IPerson> persons)
        {
            WithTransaction(() =>
            {
                foreach (var person in persons)
                {
                    var team = person.GetTeam(contest);
                    if (team == null)
                    {
                        continue;
                    }

                    var association = team.RemovePlayer(person);
                    UnitOfWorks.Delete(association);

                    if (team.Members.Count != 0)
                    {
                        continue;
                    }

                    contest.UnRegister(team);
                    UnitOfWorks.Delete(team);
                }
            });
        }
Exemplo n.º 2
0
 public void SaveContest(IContest currentContest)
 {
     WithTransaction(() =>
     {
         UnitOfWorks.Save(currentContest);
         foreach (var field in currentContest.FieldList)
         {
             UnitOfWorks.Save(field);
         }
         foreach (var phase in currentContest.PhaseList)
         {
             UnitOfWorks.Save(phase);
             foreach (var gameStep in phase.GameStepList)
             {
                 UnitOfWorks.Save(gameStep.CurrentMatchSetting);
                 UnitOfWorks.Save(gameStep);
                 foreach (var team in gameStep.TeamGameStepList)
                 {
                     UnitOfWorks.Save(team);
                 }
                 foreach (var match in gameStep.MatchList)
                 {
                     UnitOfWorks.Save(match);
                 }
             }
             foreach (var teamPhase in phase.TeamPhaseList)
             {
                 UnitOfWorks.Save(teamPhase);
             }
         }
     });
 }
Exemplo n.º 3
0
 private static void RegisterTeam(IContest contest, int countTeamToRegister)
 {
     for (var i = 1; i <= countTeamToRegister; i++)
     {
         contest.Register(CreateTeamStub(i).Object);
     }
 }
Exemplo n.º 4
0
 public PhaseViewer(IContest contest)
 {
     InitializeComponent();
     DataContext = new PhaseViewerVm(contest);
     var timer = new DispatcherTimer();
     timer.Tick += Scroll;
     timer.Interval = TimeSpan.FromMilliseconds(5);
     timer.Start();
 }
        private void buttonAddContest_Click(object sender, EventArgs e)
        {
            if (m_TabIndex < k_MaxNumberOfContests)
            {
                TabPageObserver tabPageContest = new TabPageObserver();

                if (m_TabIndex == 0)
                {
                    tabPageContest.Padding = new Padding(3);
                }

                FormAddContest newFormContest = new FormAddContest();
                newFormContest.ShowDialog();

                if (newFormContest.DialogResult == DialogResult.OK)
                {
                    IContest newContest = ContestFactory.CreateContest(
                        m_TabIndex + 1,
                        newFormContest.Status,
                        newFormContest.ImagePath,
                        newFormContest.NumberOfWinners,
                        newFormContest.LikeRequired,
                        newFormContest.CommentRequired);
                    m_ListOfContests.Add(newContest);

                    try
                    {
                        newContest.PostContestStatus();
                    }
                    catch (FacebookOAuthException)
                    {
                        MessageBox.Show("Failed to post status: No permissions.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    tabPageContest.Location = new Point(104, 4);
                    tabPageContest.Name     = string.Format("tabPageContest{0}", m_TabIndex + 1);
                    tabPageContest.Size     = new Size(867, 616);
                    tabPageContest.TabIndex = m_TabIndex;
                    tabPageContest.Text     = string.Format("Contest {0}", m_TabIndex + 1);
                    tabPageContest.UseVisualStyleBackColor = true;
                    tabControlContest.Controls.Add(tabPageContest);
                    buildContest(tabPageContest);
                    m_TabIndex++;

                    m_ReportDeletedContestDelegate += tabPageContest.m_ReportDeletedContestObserver;
                }
            }
            else
            {
                MessageBox.Show("You have reached the maximum number of contests.");
            }
        }
Exemplo n.º 6
0
 public void Notify(IContest contestant)
 {
     if (!isWinner)
     {
         UserInterface.WinnerMessage(contestant);
     }
     else
     {
         UserInterface.LoserMessage(contestant);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contest"></param>
        /// <param name="rollInput"></param>
        /// <returns>The amount of pins that can be thrown on next throw, -1 if player game is done</returns>
        public static int Roll(this IContest contest, Roll rollInput)
        {
            IContestant contestant = contest.Contestants.FirstOrDefault(x => x.ContestantName == rollInput.ContestantName);
            int         pins       = 0;

            if (!contestant.IsInstanceComplete)
            {
                pins = contestant.Roll(rollInput.PinsKnocked);
            }

            return(contestant.IsInstanceComplete ? -1 : pins);
        }
Exemplo n.º 8
0
 public Team(IContest contest, string name)
     : this()
 {
     Contest   = contest;
     Name      = name;
     MatchList = new List <IMatch>();
     Members   = new List <IRelationship <ITeam, IPerson> >();
     _gameStepTeamRelationshipList =
         new Lazy <IList <IRelationship <ITeam, IGameStep> > >(() => new List <IRelationship <ITeam, IGameStep> >());
     _phaseTeamRelationshipList =
         new Lazy <IList <IRelationship <ITeam, IPhase> > >(() => new List <IRelationship <ITeam, IPhase> >());
 }
Exemplo n.º 9
0
        public void CreateTeam(IContest contest, string name, IList <IPerson> persons)
        {
            WithTransaction(() =>
            {
                var team = TeamFactory.Create(contest, name);
                UnitOfWorks.Save(team);

                foreach (var person in persons)
                {
                    var association = team.AddPlayer(person);
                    UnitOfWorks.Save(association);
                }
            });
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Create a new instance (in memory and database) of <see cref="T:Business.Team" /> with specified param
        /// </summary>
        /// <param name="contest">Contest in wich new team was involved</param>
        /// <param name="name">Name of new team</param>
        /// <returns>Team's instance</returns>
        public ITeam Create(IContest contest, string name)
        {
            if (contest == null)
            {
                throw new ArgumentNullException(nameof(contest));
            }
            var existingTeams = TeamRepository.Find(_ => _.ContestId == contest.Id && _.Name == name);

            if (existingTeams != null && existingTeams.Count() != 0)
            {
                throw new ArgumentException("Le nom de l'équipe est déjà utilisé.");
            }

            var result = new Team(contest, name);

            contest.Register(result);
            return(result);
        }
Exemplo n.º 11
0
        public Field(IContest current, string name)
            : this()
        {
            if (current == null)
            {
                throw new ArgumentException("current");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            FlippingContainer.Instance.ComposeParts(this);

            Name           = name;
            CurrentContest = current;
            MatchInProgess = null;
        }
Exemplo n.º 12
0
        public void UpdateContest(IContest contest)
        {
            WithTransaction(() =>
            {
                UnitOfWorks.Save(contest.EliminationSetting.MatchSetting);
                UnitOfWorks.Save(contest.EliminationSetting);

                if (contest.QualificationSetting != null)
                {
                    UnitOfWorks.Save(contest.QualificationSetting.MatchSetting);
                    UnitOfWorks.Save(contest.QualificationSetting);
                }

                if (contest.ConsolingEliminationSetting != null)
                {
                    UnitOfWorks.Save(contest.ConsolingEliminationSetting.MatchSetting);
                    UnitOfWorks.Save(contest.ConsolingEliminationSetting);
                }
            });
        }
        private void updateRequirementsCheckBoxes(IContest i_Contest, CheckBox i_CheckBoxCommentCondition, CheckBox i_CheckBoxLikeCondition)
        {
            if (i_Contest is ContestByLikes)
            {
                i_CheckBoxLikeCondition.Checked    = true;
                i_CheckBoxCommentCondition.Checked = false;
            }

            if (i_Contest is ContestByComments)
            {
                i_CheckBoxLikeCondition.Checked    = false;
                i_CheckBoxCommentCondition.Checked = true;
            }

            if (i_Contest is ContestByLikesAndComments)
            {
                i_CheckBoxLikeCondition.Checked    = true;
                i_CheckBoxCommentCondition.Checked = true;
            }
        }
Exemplo n.º 14
0
        private void calculateTracksButton_Click(object sender, EventArgs e)
        {
            if (_swimmers.Count <= 0)
            {
                MessageBox.Show("Для начала добавтьте плавцов через форму с лева.", "Ошибка");
            }
            else
            {
                ContestCreator qualifyingContestCreator = new QualifyingContestCreator();
                ContestCreator finalContestCreator      = new FinalContestCreator();
                IContest       qualifyingContest        = qualifyingContestCreator.FactoryMethod();
                IContest       finalContest             = finalContestCreator.FactoryMethod();


                QualifyingContestTextBox.Enabled = true;
                FinalContestTextBox.Enabled      = true;

                QualifyingContestTextBox.Text = swimmersListToString(qualifyingContest.SortSwimmersByTracks(_swimmers));
                FinalContestTextBox.Text      = swimmersListToString(finalContest.SortSwimmersByTracks(_swimmers));
            }
        }
Exemplo n.º 15
0
        public ContestViewVm(IContest contest)
        {
            if (contest == null)
            {
                throw new ArgumentNullException(nameof(contest));
            }
            if (contest.EliminationSetting == null)
            {
                throw new InvalidProgramException("Elimination setting can not be null.");
            }

            FirstEliminationStep = contest.EliminationSetting.FirstStep;
            EliminationSettingVm = new MatchSettingVm(contest.EliminationSetting.MatchSetting);
            HasQualificationStep = contest.WithQualificationPhase;
            HasConsolingStep     = contest.WithConsolante;

            if (contest.QualificationSetting != null)
            {
                CountQualificationGroup = contest.QualificationSetting.CountGroup;
                WithRevenge             = contest.QualificationSetting.MatchWithRevenche;

                QualificationSettingVm = new MatchSettingVm(contest.QualificationSetting.MatchSetting);
            }
            else
            {
                QualificationSettingVm = new MatchSettingVm();
            }

            if (contest.ConsolingEliminationSetting != null)
            {
                FirstConsolingEliminationStep = contest.ConsolingEliminationSetting.FirstStep;
                ConsolingEliminationSettingVm = new MatchSettingVm(contest.ConsolingEliminationSetting.MatchSetting);
            }
            else
            {
                ConsolingEliminationSettingVm = new MatchSettingVm();
            }

            CurrentContest = contest;
        }
Exemplo n.º 16
0
        public PhaseViewerVm(IContest contest)
        {
            if (contest == null)
            {
                throw new ArgumentNullException(nameof(contest));
            }

            PhaseList = contest.PhaseList.Select(_ => new PhaseViewItem(_)).ToList();
            contest.NewPhaseLaunch += (sender, phase) => PhaseList.Add(new PhaseViewItem(phase));
            var timer = new DispatcherTimer();

            timer.Tick    += RefreshClock;
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Start();


            WatchNextPhase();

            timer          = new DispatcherTimer();
            timer.Tick    += ChangePhase;
            timer.Interval = TimeSpan.FromSeconds(60);
            timer.Start();
        }
 public DeadlineByParticipantsLimit(IContest contest)
 {
     this.contest = contest;
 }
Exemplo n.º 18
0
 public static void LoserMessage(IContest contestant)
 {
     Console.WriteLine("Sorry but you are not a winner {0}", contestant);
 }
Exemplo n.º 19
0
 protected ContestDecorator(IContest decoratedContest)
 {
     DecoratedContest = decoratedContest;
 }
Exemplo n.º 20
0
 public AddTeamMemberVm(IContest currentContest, IList <IPerson> selectedPlayers)
 {
     SelectedPlayers   = selectedPlayers;
     AvailableTeamList = currentContest.TeamList.Where(_ => _.Members.Count < currentContest.MaximumPlayerByTeam).ToList();
     SelectedTeam      = AvailableTeamList.FirstOrDefault();
 }
 public OpenVotingStartegy(IContest contest)
 {
     this.contest = contest;
 }
 public ContestsController(IContest repo)
 {
     this._repo = repo;
     this.vm    = new ContestViewModel(_repo);
 }
 public OpenParticipationStrategy(IContest contest)
 {
     this.contest = contest;
 }
Exemplo n.º 24
0
 /// <summary>
 ///     Create a new instance of Field with specified param
 /// </summary>
 /// <param name="current">Current contest</param>
 /// <param name="name">Name of new field</param>
 /// <returns>Field's instance</returns>
 public IField Create(IContest current, string name)
 {
     return(new Field(current, name));
 }
Exemplo n.º 25
0
 public ContestDecoratorMoreThanSeven(IContest decoratedContest) : base(decoratedContest)
 {
 }
Exemplo n.º 26
0
 public static void WinnerMessage(IContest contestant)
 {
     Console.WriteLine("Congratulations on winning {0}", contestant);
 }
Exemplo n.º 27
0
 public SingleWinner(IContest contest)
 {
     this.contest = contest;
 }
 public ClosedParticipationStrategy(IContest contest)
 {
     this.contest = contest;
 }
Exemplo n.º 29
0
 public RegisterTeamVm(IContest contest, IList <IPerson> selectedPlayerList)
 {
     _contest            = contest;
     _selectedPlayerList = selectedPlayerList;
     FlippingContainer.Instance.ComposeParts(this);
 }
 public BowlingController(IContest bowlingGame)
 {
     _bowlingGame = bowlingGame;
 }
Exemplo n.º 31
0
 public void UpdateContest(IContest contest)
 {
     _db.Update(contest);
 }
 public ClosedVotingStartegy(IContest contest)
 {
     this.contest = contest;
 }
Exemplo n.º 33
0
 public void AddContest(IContest contest)
 {
     _db.Insert(contest);
 }
 public ContestDecoratorOdd(IContest decoratedContest) : base(decoratedContest)
 {
 }
Exemplo n.º 35
0
 public PlayerListVm(IContest contest)
 {
     FlippingContainer.Instance.ComposeParts(this);
     Contest = contest ?? throw new ArgumentNullException(nameof(contest));
     RefreshPlayerList(null, null);
 }
 public MultipleWinners(IContest contest)
 {
     this.contest = contest;
 }
 public ContestViewModel(IContest repo)
 {
     this._repo = repo;
 }
 public DeadlineByEndDate(IContest contest)
 {
     this.contest = contest;
 }
 public ContestDecoratorFLZero(IContest decoratedContest) : base(decoratedContest)
 {
 }
Exemplo n.º 40
0
 public PersonVm(IContest contest, IPerson person)
 {
     _contest = contest;
     Person   = person;
 }