Ejemplo n.º 1
0
    public VoteEventArgs Vote(string question)
    {
        VoteEventArgs voteEventArgs = new VoteEventArgs();

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

            VoteEventArgs e = new VoteEventArgs();

            FireBeforeSubmitVote(e);

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

            return(retval);
        }
Ejemplo n.º 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;
        }
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 9
0
        public bool Submit()
        {
            bool retval = false;

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

            if (!e.Cancel) {

                retval = true;
                FireAfterSubmitVote(e);
            }

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