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(); }
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); }
/// <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()); } }
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; } }
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); } } }
public bool Delete(int ID) { bool b1 = ur.Delete(ID); return(b1); }