public IVote VoteOnArtist(IVote vote) { IVote voteAdded = new Vote(); IDataQuery query = new DataQuery(); query.Where = string.Format("profileId={0} and songId={1} and battlId={2}", vote.ProfileId, vote.SongId, vote.BattlId); IVote result = _voteRepository.Find(query).FirstOrDefault(); if (result != null) { vote.VoteId = result.VoteId; vote.Votes = result.Votes + 1; voteAdded = _voteRepository.Update(vote); } else { voteAdded = _voteRepository.Add(vote); } query.Where = string.Format("songId={0} and battlId={1}", vote.SongId, vote.BattlId); int resultTotal = CanGetVotesByWhere(query.Where).Sum(m => m.Votes); vote.Votes = resultTotal; return(voteAdded); }
public void ProcessRequest(HttpContext context) { if(null == _voteSource) { lock(_voteSourceLock) { if (null == _voteSource) _voteSource = (IVote)HttpContext.Current.Application["VoteSource"]; } } switch(context.Request.HttpMethod) { case "POST": var vi = ParsePayload(context.Request); context.Response.StatusCode = 202; context.Response.ContentType = "application/json"; context.Response.Write("{status: \"Accepted\""); if(!string.IsNullOrEmpty(vi.DoorID)) { _voteSource.PostVote(vi); } break; default: var v = ParsePayload(context.Request); context.Response.ContentType = "text/plain"; context.Response.Write(string.Format("Welcome to the Door Competition voting service. You can post your vote to this endpoint. DoorID: {0}",v.DoorID)); break; } }
public DisplayController(IBallot ballot, ISeatService seatService, IMember member, ICouncilSession session, IVote vote) { _ballot = ballot; _member = member; _session = session; _vote = vote; _seatService = seatService; }
public Game(IEnumerable<IPlayer> players, IEnumerable<IMission> missions, IVote votingSystem ) { _players = (players ?? Enumerable.Empty<IPlayer>()).ToList(); _missions = (missions ?? Enumerable.Empty<IMission>()).ToList(); PlayerCount = _players.Count(); _votingSystem = votingSystem; State = GameState.NotReady; }
static VoteService() { if (null == _voteSource) { lock (_voteSourceLock) { if (null == _voteSource) _voteSource = (IVote)HttpContext.Current.Application["VoteSource"]; } } }
public ProfileController(SignInManager <CreateUsers> signout, IUserImages userimage, IDatabaseRepository <UserImages> databaseuserimages, IVote votes, IDatabaseRepository <Vote> voterepository) { this.signout = signout; this.userimage = userimage; this.databaseuserimages = databaseuserimages; this.votes = votes; this.voterepository = voterepository; }
public V SendVoting(T Message, IVote <V> Vote) { if (OnVoting == null) { return(Vote.Result); } OnVoting?.Invoke(Message, Vote); return(Vote.Result); }
public async Task <VoteResult> VoteAsync(IVote vote) { try { var entity = VoteEntity.Create(vote); await _tableStorage.InsertAsync(entity); return(VoteResult.Accepted); } catch (Exception) { return(VoteResult.VoteIsAlreadyMade); } }
public static VoteEntity Create(IVote src) { var result = new VoteEntity { PartitionKey = GeneratePartitionKey(), RowKey = GenerateRowKey(src.Email), Email = src.Email, UserId = src.UserId, Comment = src.Comment, Created = src.Created }; result.SetOption(src.Option); return(result); }
public async Task <IActionResult> MyVote(MyVoteContract model) { //return Redirect(urlToRedirect); if (model.NotVoted()) { return(RedirectToAction("Vote")); } if (string.IsNullOrEmpty(model.Token)) { var user = this.GetUser(); if (user == null) { return(RedirectToAction("Signin")); } model.Email = user.Email; model.UserId = user.UserId; } else { var token = await _voteTokensRepository.FindTokenAsync(model.Token); if (token == null) { return(RedirectToAction("Signin")); } model.Email = token.Email; } IVote vote = await _votesRepository.GetAsync(model.Email); if (vote != null) { return(RedirectToAction("Success")); } await _votesRepository.VoteAsync(model); return(RedirectToAction("Success")); }
public HomeController(ILogger <HomeController> logger, IMemberRegister memberRegister, ICouncilSession session, IBallot ballot, IMember member, IVote vote, ISeatService seatService, IConfiguration configuration) { _configuration = configuration; _memberRegister = memberRegister; _session = session; _ballot = ballot; _member = member; _vote = vote; _logger = logger; _seatService = seatService; model = new HomeIndexViewModel { Session = _session.GetActiveSession(), Ballot = _ballot.GetActiveOrLast() }; }
public static VoteEntity Create(IVote src) { var result = new VoteEntity { PartitionKey = GeneratePartitionKey(), RowKey = GenerateRowKey(src.UserId), Email = "---", UserId = src.UserId, Option1 = src.Option1, Option2 = src.Option2, Option3 = src.Option3, Comment = src.Comment, Created = src.Created }; return(result); }
/** * Alows the Student to place their vote on a Candidate after confirmation */ public ActionResult Voting(int id) { string currentUserID = ""; // Determine what role is the Student // capture the id of the Student that is voting for any roles if (TempData.ContainsKey("StudentRole")) { string studentRole = TempData["StudentRole"].ToString(); if (studentRole.Equals("Candidate")) { currentUserID = TempData["CandidateID"].ToString(); TempData["CandidateID"] = currentUserID; iVote = new Candidate(); } else if (studentRole.Equals("Voter")) { currentUserID = TempData["VoterID"].ToString(); TempData["VoterID"] = currentUserID; iVote = new Voter(); } else if (studentRole.Equals("Admin")) { currentUserID = TempData["AdminID"].ToString(); TempData["AdminID"] = currentUserID; iVote = new Admin(); } TempData["StudentRole"] = studentRole; // Vote for the candidate by passing the candidate ID and the current user ID iVote.Vote(id, Convert.ToInt32(currentUserID)); // TODO TempData["msg"] = "<script>alert('Change succesfully');</script>"; // redirect to stats page return(RedirectToAction("Stats", "Home")); } return(RedirectToAction("Login", "Home")); }
public ImageController(IDatabaseRepository <UserImages> userimages, IJsonCache <UserImages> cacheimage, IDatabaseRepository <Vote> databasevote, IDatabaseRepository <Comments> databasecomment, IDatabaseRepository <Category> categoryrepository, IJsonCache <Category> categorycache, IVote updatevote, IUserImages user, IComments comments) { this.userimages = userimages; this.cacheimage = cacheimage; this.databasevote = databasevote; this.updatevote = updatevote; this.comments = comments; this.databasecomment = databasecomment; this.categoryrepository = categoryrepository; this.categorycache = categorycache; this.user = user; }
public static Vote TransformToVote(IVote vote) { var newVote = new Vote { Bill = Bill.TransformToBill(vote.Bill), BillId = vote.BillId, Chamber = vote.Chamber, Description = vote.Description, Nomination = vote.Nomination, NominationId = vote.NominationId, Question = vote.Question, Result = vote.Result, Source = vote.Source, //Type = vote.Type, VoteCastedByLegislator = vote.VoteCastedByLegislator, VotedAt = vote.VotedAt, VoteResults = vote.VoteResult }; return(newVote); }
public ActionResult Index() { if (Authentication.User.Identity.IsAuthenticated) { // Determine what role is the Student if (TempData.ContainsKey("StudentRole")) { string studentRole = TempData["StudentRole"].ToString(); if (studentRole.Equals("Candidate")) { iVote = new Candidate(); } else if (studentRole.Equals("Voter")) { iVote = new Voter(); } else if (studentRole.Equals("Admin")) { iVote = new Admin(); } TempData["StudentRole"] = studentRole; // if current user has voted, send them to the results page if (iVote.hasCurrentUserVoted()) { return(RedirectToAction("Stats", "Home")); } } // allow them to see all the candidates to vote return(View(iCandidateProfile.ViewAllProfiles())); } else { //redirection to the action of login in the AccountController return(RedirectToAction("Login", "Home")); } }
public IVote VoteOnArtist(IVote vote) { IVote voteAdded = new Vote(); IDataQuery query = new DataQuery(); query.Where = string.Format("profileId={0} and songId={1} and battlId={2}", vote.ProfileId, vote.SongId, vote.BattlId); IVote result = _voteRepository.Find(query).FirstOrDefault(); if (result != null) { vote.VoteId = result.VoteId; vote.Votes = result.Votes + 1; voteAdded = _voteRepository.Update(vote); } else { voteAdded = _voteRepository.Add(vote); } query.Where = string.Format("songId={0} and battlId={1}", vote.SongId, vote.BattlId); int resultTotal = CanGetVotesByWhere(query.Where).Sum(m => m.Votes); vote.Votes = resultTotal; return voteAdded; }
public void Remove(IVote entity) { base.Remove((StoryVote)entity); }
/// <summary> /// Vote 'yes' or 'ok' or 'allow' or 'accept'. /// </summary> public static void Accept(this IVote <Boolean> Vote) { Vote.VoteFor(true); }
/// <summary> /// Vote 'yes' or 'ok' or 'allow' or 'accept'. /// </summary> public static void Yes(this IVote <Boolean> Vote) { Vote.VoteFor(true); }
/// <summary> /// Vote 'no' or 'deny'. /// </summary> public static void Deny(this IVote <Boolean> Vote) { Vote.VoteFor(false); }
public virtual void AddVote(ISurvey pSurvey, IVote pVote) { throw new System.NotImplementedException(); }
private Game PrepareGameInWaitingForMissionState(IEnumerable<IPlayer> players, IEnumerable<IMission> missions, IEnumerable<IPlayer> spies = null, IPlayer leader = null, IVote votingSystem = null) { Game game = PrepareGameInSelectLeaderState(players, missions, spies, votingSystem); game.SelectLeader(leader ?? game.Players.First()); Assert.AreEqual(GameState.WaitingForMission, game.State); return game; }
public VoteController() { var bl = new BusinessManager(); _vote = bl.GetVote(); }
/// <summary> /// This method adds a vote to this survey and verifies if all votes were made. If this is the case a statChanged /// event with state finished will be fired. It will also check if the user still has open votes /// </summary> /// <param name="pVote">The vote to ass</param> public virtual void AddVote(IVote pVote) { if (_voteList.Count(x => x.User == pVote.User) < MaxVotesPerUser) { _voteList.Add(pVote); List<InteractionAttributes> changedAttributes = new List<InteractionAttributes> {InteractionAttributes.VoteList}; OnModify(new InteractionEventArgs($"Survey votes changed [Id={Id}]", DateTime.Now, InteractionType.Survey)); } // Is completed? if (_voteList.Count >= (MaxVotesPerUser*UserList.Count)) { _isActive = false; ChangeState(InteractionState.Finished); } }
public void Add(IVote entity) { base.Add((StoryVote)entity); }
public VoteController(IVote vote_) { voteService = vote_; }
private Game PrepareFreshGame(IEnumerable<IPlayer> players, IEnumerable<IMission> missions, IVote votingSystem = null) { return new Game(players, missions, votingSystem); }
public virtual bool UpsertVote(IVote pVote) { throw new System.NotImplementedException(); }
public static void RemoveVote(this IStory fromStory, IVote vote) { Check.Argument.IsNotNull(fromStory, "fromStory"); Check.Argument.IsNotNull(vote, "vote"); IoC.Resolve <IVoteRepository>().Remove(vote); }
public void AddVote(IVote vote) { _db.Insert(vote); }
public PollsController(UserManager <ApplicationUser> userManager, IPoll polls, IVote votes) { _userManager = userManager; _polls = polls; _votes = votes; }
public PostsController(IPostService postService, IVote voteService) { this._postService = postService; this._voteService = voteService; }
private Game PrepareGameInSelectLeaderState(IEnumerable<IPlayer> players, IEnumerable<IMission> missions, IEnumerable<IPlayer> spies = null, IVote votingSystem = null) { Game game = PrepareFreshGame(players, missions, votingSystem); game.SelectSpies(spies); Assert.AreEqual(GameState.SelectingLeader, game.State); return game; }
public virtual void AddVote(IVote pOption) { throw new System.NotImplementedException(); }
public V ProcessVoting(T1 Message1, T2 Message2, IVote <V> Vote) { Console.WriteLine("VotingTarget<T1, T2>" + Message1 + " / " + Message2 + " => true"); return(default(V)); }