예제 #1
0
    public VoteEventArgs Vote(string question)
    {
        VoteEventArgs voteEventArgs = new VoteEventArgs();

        voteEventArgs.Question = question;
        OnVote?.Invoke(this, voteEventArgs);
        return(voteEventArgs);
    }
예제 #2
0
 private void voteManager_VoteAdded(object sender, VoteEventArgs args)
 {
     if (Requester.IsLogged && !Portal.Request.IsRequesterAttached(args.RequestID.Value, Requester.LoggedUserID.Value))
     {
         var dto = new RequestRequesterDTO();
         dto.RequestID   = args.RequestID.Value;
         dto.RequesterID = Requester.Logged.ID;
         Portal.Request.AddRequester(args.RequestID.Value, dto);
     }
 }
예제 #3
0
        /// <summary>
        /// Add a new vote
        /// </summary>
        /// <param name="vote"></param>
        /// <returns></returns>
        public Vote Add(Vote vote)
        {
            var e = new VoteEventArgs {Vote = vote};
            EventManager.Instance.FireBeforeVoteMade(this, e);

            if (!e.Cancel)
            {
                _context.Vote.Add(vote);

                EventManager.Instance.FireAfterVoteMade(this, new VoteEventArgs {Vote = vote});
            }

            return vote;
        }
예제 #4
0
        public bool Submit()
        {
            bool retval = false;

            VoteEventArgs e = new VoteEventArgs();

            FireBeforeSubmitVote(e);

            if (!e.Cancel)
            {
                retval = true;
                FireAfterSubmitVote(e);
            }

            return(retval);
        }
예제 #5
0
    public void VoterHandler(object sender, VoteEventArgs e)
    {
        switch (new Random().Next(0, 3))
        {
        case 0:
            e.VoteFor += 1;
            break;

        case 1:
            e.VoteAgaints += 1;
            break;

        case 2:
            e.VoteAbstained += 1;
            break;
        }
    }
예제 #6
0
    static void Main(string[] args)
    {
        ElectoralComission electoralComission = new ElectoralComission();

        Voiter[] voiters = new Voiter[10];
        for (int i = 0; i < 10; i++)
        {
            voiters[i] = new Voiter();
            electoralComission.OnVote += voiters[i].VoterHandler;
        }

        VoteEventArgs voteEventArgs = electoralComission.Vote("Привет?");

        Console.WriteLine($"Вопрос был: {voteEventArgs.Question}");
        Console.WriteLine($"\tЗа проголосовали:\t\t {voteEventArgs.VoteFor}");
        Console.WriteLine($"\tПротив проголосовали:\t\t {voteEventArgs.VoteAgaints}");
        Console.WriteLine($"\tВоздержались от голосования:\t {voteEventArgs.VoteAbstained}");
        Console.ReadKey();
    }
예제 #7
0
        /// <summary>
        /// Add a new vote
        /// </summary>
        /// <param name="vote"></param>
        /// <returns></returns>
        public Vote Add(Vote vote)
        {
            var e = new VoteEventArgs {
                Vote = vote
            };

            EventManager.Instance.FireBeforeVoteMade(this, e);

            if (!e.Cancel)
            {
                _context.Vote.Add(vote);

                EventManager.Instance.FireAfterVoteMade(this, new VoteEventArgs {
                    Vote = vote
                });
            }

            return(vote);
        }
예제 #8
0
        /// <summary>
        /// Add a new vote
        /// </summary>
        /// <param name="vote"></param>
        /// <returns></returns>
        public Vote Add(Vote vote)
        {
            var e = new VoteEventArgs {
                Vote = vote, Api = _api
            };

            EventManager.Instance.FireBeforeVoteMade(this, e);

            if (!e.Cancel)
            {
                _voteRepository.Add(vote);

                EventManager.Instance.FireAfterVoteMade(this, new VoteEventArgs {
                    Vote = vote, Api = _api
                });
            }

            return(vote);
        }
예제 #9
0
        public bool Submit()
        {
            bool retval = false;

            VoteEventArgs e = new VoteEventArgs();
            FireBeforeSubmitVote(e);

            if (!e.Cancel) {

                retval = true;
                FireAfterSubmitVote(e);
            }

            return retval;
        }
예제 #10
0
 protected virtual void FireBeforeSubmitVote(VoteEventArgs e)
 {
     _e.FireCancelableEvent(BeforeSubmitVote, this, e);
 }
예제 #11
0
 protected virtual void FireAfterSubmitVote(VoteEventArgs e)
 {
     _e.FireCancelableEvent(AfterSubmitVote, this, e);
 }
예제 #12
0
 private void EventManagerInstanceAfterVoteMade(object sender, VoteEventArgs args)
 {
     _eventTestStr = TestString;
 }
예제 #13
0
 private void EventManagerInstanceBeforeVoteMadeCancel(object sender, VoteEventArgs args)
 {
     args.Cancel = true;
 }
예제 #14
0
 private void EventManagerInstanceBeforeVoteMadeAllow(object sender, VoteEventArgs args)
 {
     args.Cancel = false;
 }
예제 #15
0
 protected virtual void FireAfterSubmitVote(VoteEventArgs e)
 {
     _e.FireCancelableEvent(AfterSubmitVote, this, e);
 }
예제 #16
0
 protected virtual void FireBeforeSubmitVote(VoteEventArgs e)
 {
     _e.FireCancelableEvent(BeforeSubmitVote, this, e);
 }