Exemplo n.º 1
0
        private static async Task VerifyVoteDelete(VoteRepository repository, int warId, Guid matchId)
        {
            await repository.Delete(warId, matchId);

            var afterDelete = await repository.Get(warId, matchId);

            afterDelete.Should().BeNullOrEmpty();
        }
Exemplo n.º 2
0
        public void Delete_Normal_Conditions()
        {
            var repo = new VoteRepository();
            var vote = new Vote();

            vote.OptionId = 2;
            vote.SurveyId = 3;
            var count = repo.GetAll().Count();

            repo.Add(vote);
            repo.Delete(vote);
            Assert.IsTrue(repo.GetAll().Count() == count);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Delete API/Vote/{id}
 /// </summary>
 /// <param name="id">id du Vote à supprimer</param>
 public IHttpActionResult Delete(int id)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         if (repo.GetOne(id) == null)
         {
             return(NotFound());
         }
         else
         {
             repo.Delete(id);
             return(Ok());
         }
     }
     else
     {
         return(Unauthorized());
     }
 }
Exemplo n.º 4
0
        private void Consumer_RabbitReceived(RabbitMqMessage message, string consumer)
        {
            switch (message.Action)
            {
            case RabbitMqAction.Delete:
                int articleId            = int.Parse(message.Data.ToString());
                IEnumerable <Vote> votes = voteRepository.GetArticle(articleId);

                foreach (Vote vote in votes)
                {
                    voteRepository.Delete(vote.Id);
                }

                Console.WriteLine("RabbitMQ: " + votes.Count() + " votes Deleted.");
                break;

            default:
                Console.WriteLine("Unknown RabbitMQ Message.");
                break;
            }
        }
Exemplo n.º 5
0
        internal void Vote(string debate_id, string voteCasted, string userVoting)
        {
            Vote vote = new DatabaseAccess.Vote();

            vote.debate_id     = int.Parse(debate_id);
            vote.user_username = userVoting;
            if (voteCasted == "pro")
            {
                vote.vote_pro = true;
            }
            else
            {
                vote.vote_pro = false;
            }

            try
            {
                Vote debateVote = _voteRepository.GetDebateVote(int.Parse(debate_id), userVoting);
                if (debateVote.vote_pro == vote.vote_pro)
                {
                    _voteRepository.Delete(debateVote.vote_id);
                }
                else
                {
                    debateVote.vote_pro = vote.vote_pro;
                    _voteRepository.Update(debateVote);
                }
            }
            catch (VoteException vex)
            {
                if (vex.Message == "333")
                {
                    _voteRepository.Add(vote);
                }
            }
        }
Exemplo n.º 6
0
        public bool Delete(int ID)
        {
            bool b1 = ur.Delete(ID);

            return(b1);
        }