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

        voteEventArgs.Question = question;
        OnVote?.Invoke(this, voteEventArgs);
        return(voteEventArgs);
    }
Example #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);
     }
 }
Example #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;
        }
Example #4
0
        public bool Submit()
        {
            bool retval = false;

            VoteEventArgs e = new VoteEventArgs();

            FireBeforeSubmitVote(e);

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

            return(retval);
        }
Example #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;
        }
    }
Example #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();
    }
Example #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);
        }
Example #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);
        }
Example #9
0
        public bool Submit()
        {
            bool retval = false;

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

            if (!e.Cancel) {

                retval = true;
                FireAfterSubmitVote(e);
            }

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