Пример #1
0
 public bool CheckPolicy(int pollId)
 {
     foreach (var a in _userRepos.GetAllAccessPolicies(_contextRegistration.GetLoggedUser().Id))
     {
         if (a.PollId == pollId)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
        public Vote Vote(List <int> Idchoices)
        {
            var vote = new Vote()
            {
                UserId      = _contextRegistration.GetLoggedUser().Id,
                VoteDate    = DateTime.Now,
                VoteChoices = new List <VoteChoice>()
            };

            foreach (var choiceId in Idchoices)
            {
                vote.VoteChoices.Add(new VoteChoice()
                {
                    choiceId = choiceId
                });
            }

            _voteRepos.Create(vote);
            return(vote);
        }
Пример #3
0
        public Dictionary <bool, string> CheckAllPolicy(string temp_name)
        {
            Dictionary <bool, string> allResponses = new Dictionary <bool, string>();
            Poll poll           = _pollRepos.Get(temp_name);
            bool policyresponse = _policyChecker.CheckPolicy(poll.Id);

            if (!policyresponse)
            {
                string policyAnswer = "You are not allowed to vote!";
                allResponses.Add(policyresponse, policyAnswer);
                return(allResponses);
            }
            bool multiplevoteresponse = _voteRepos.IsVoted(_contextRegistration.GetLoggedUser().Id, temp_name);

            if (multiplevoteresponse)
            {
                string voteAnswer = "You have already voted!";
                allResponses.Add(multiplevoteresponse, voteAnswer);
                return(allResponses);
            }
            return(new Dictionary <bool, string>());
        }