public double InsertNewVote(int songid, string username, double point) { DBMusicDataContext db = new DBMusicDataContext(); vote v = new vote(); double p; v = db.votes.FirstOrDefault(x => x.username == username && x.songid == songid); if (v != null) { return(0); } try { v = new vote(); v.songid = songid; v.username = username; v.point = point; db.votes.InsertOnSubmit(v); db.SubmitChanges(); } catch { return(0); } p = Point(songid); return(p); }
public int Vote(int letter_id, string user_ip) { db_mysql db_mysql = new db_mysql(); db_mssql db_mssql = new db_mssql(); letter letterToView = (from l in db_mysql.letters where l.Id == letter_id select l).FirstOrDefault(); vote loveVote = new vote(); loveVote.letterID = letter_id; loveVote.voterIP = user_ip; loveVote.voteValue = 1; loveVote.voteDate = DateTime.Now; db_mssql.votes.Add(loveVote); db_mssql.SaveChanges(); db_mysql.letters.Attach(letterToView); var letter = db_mysql.Entry(letterToView); letter.Property(e => e.letterUp).IsModified = true; letterToView.letterUp = (short)(letterToView.letterUp + 1); db_mysql.SaveChanges(); return (int)letterToView.letterUp; }
public async void tryVote(object sender, EventArgs e) { vote newVote = new vote(); newVote.playerId = player.id; newVote.matchId = matchId; var deviceId = await App.VoteRepo.GetDeviceId(); newVote.deviceId = deviceId.id; bool status = await manager.votingHandler(newVote); if (status == false) { eMessage.IsVisible = true; eMessage.Text = "Du har allerede stemt!"; } else { succes.IsVisible = true; succes.BackgroundColor = Color.FromHsla(255, 255, 255, 0.8); newPNumber.Text = "#" + player.playerNumber; transparentBox.IsVisible = false; transparentBoxText.IsVisible = false; } }
public bool votingHandler([FromBody] vote newVote) { var cs = Services.ContentService; var match = cs.GetById(newVote.matchId); var votes = cs.GetChildren(newVote.matchId); bool status = false; foreach (var vote in votes) { if (votes.All(x => x.Properties["deviceId"].Value.ToString() != newVote.deviceId)) { status = true; } } if (status == true || votes.Count() == 0) { status = true; var nVote = cs.CreateContent(newVote.playerId.ToString(), newVote.matchId, "voting"); nVote.SetValue("playerId", newVote.playerId); nVote.SetValue("deviceId", newVote.deviceId); cs.SaveAndPublishWithStatus(nVote); } return(status); }
// GET: api/squadHealth/ public void Get([FromUri] vote input) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["directLocalDB"]; string sprintId = ConfigurationManager.AppSettings["sprintID"]; SqlConnection conn = new SqlConnection(settings.ToString()); string mergeCmd = "update tbl_squadHealth set colour = '" + input.colour + "' where userid ='" + input.userId + "' and questionNumber = '" + input.questionNumber + "' and sprintId = '" + input.sprintId + "'"; SqlCommand cmd = new SqlCommand(mergeCmd, conn); conn.Open(); var noOfResults = cmd.ExecuteNonQuery(); if (noOfResults == 0) { squadHealthEntities db = new squadHealthEntities(); tbl_squadHealth newObj = new tbl_squadHealth(); newObj.colour = input.colour; newObj.lastUpdateTime = Convert.ToDateTime(input.lastUpdateTime); newObj.questionNumber = Convert.ToInt16(input.questionNumber); newObj.sprintId = Convert.ToInt16(sprintId); newObj.userId = input.userId; db.tbl_squadHealth.Add(newObj); db.SaveChanges(); } }
void onDisplayAnswer(vote Vote, ref Answer answer, GameObject answerObject) { // Peek from queue and display on screen answer = answerManager.peekAnswer(); answer.setGObject(answerObject); Text txt = Vote == vote.first ? uiManager.Instance.votingAnswerTxt1 : uiManager.Instance.votingAnswerTxt2; txt.text = answer.getValue(); answerManager.deqAnswer(); }
public override void onStartPhase() { // Fill out voting queue with other clients answers. answerManager.setVotingQueue(); onTransition(phaseState.on); uiManager.setPhaseCanvas(ref uiManager.Instance.votingCanvas, true); // animate and generate top and bottom answer for vote on screen onDisplayAnswer(vote.first, ref topAnswer, uiManager.Instance.votingAnswerTxt1.gameObject); onDisplayAnswer(vote.second, ref downAnswer, uiManager.Instance.votingAnswerTxt2.gameObject); topAnswer.getGObject().GetComponent <animationManager>().play("topAnswer"); downAnswer.getGObject().GetComponent <animationManager>().play("downAnswer"); uiManager.Instance.topVoteBtn.onClick.AddListener(() => { voteChoice = vote.first; onSubmit(); }); uiManager.Instance.downVoteBtn.onClick.AddListener(() => { voteChoice = vote.second; onSubmit(); }); }
/// <summary> /// Gets the vote. /// </summary> /// <param name="vote">The vote.</param> /// <returns></returns> private Model.Vote.Vote getVote(vote vote) { Model.Vote.Vote newVote = new XareuServices.Model.Vote.Vote(); newVote.Author.Id = vote.vote_author; newVote.Author.Nick = vote.user.user_nick; newVote.Id = vote.vote_id; newVote.Karma = vote.vote_karma; newVote.Publication.Id = vote.publication.publication_id; newVote.Publication.Author.Id = vote.publication.user.user_id; newVote.Publication.Text = vote.publication.publication_text; newVote.Publication.Karma = vote.publication.publication_karma; try { newVote.Publication.IsQuestion = (bool)vote.publication.publication_is_question; } catch { newVote.Publication.IsQuestion = false; } newVote.Publication.IsPrivate = vote.publication.publlication_is_private; return(newVote); }
protected void imgBtnSave_Click(object sender, ImageClickEventArgs e) { vote votes = new vote(); MVote objvotes = new MVote(); objvotes.VoteTitle = txtTitle.Text.ToString(); objvotes.VoteContent = txtContent.Text.ToString(); bool bl = votes.InsertIntoVote(objvotes); if (bl) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('数据提交成功!');</script>"); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('网络故障,数据提交失败!');</script>"); } }
public override IEnumerator onStartJingle() { // reset UI and phase member variables voteChoice = vote.none; isActive = false; turnManager.setTime(turnManager.getLength()); soundManager.playJingle(soundManager.soundList["voteJingle"]); uiManager.setDefaultUI(); yield return new WaitForSeconds(2.25f); onStartPhase(); isActive = true; soundManager.setAmbiance(true); soundManager.playVoice(colorManager.defaultColor, " MAKE BONDS NOW ! "); answerManager.setAnswerList(); yield break; }
public override IEnumerator onStartJingle() { // reset UI and phase member variables voteChoice = vote.none; isActive = false; turnManager.setTime(turnManager.getLength()); soundManager.playJingle(soundManager.soundList["voteJingle"]); uiManager.setDefaultUI(); yield return(new WaitForSeconds(2.25f)); onStartPhase(); isActive = true; soundManager.setAmbiance(true); soundManager.playVoice(colorManager.defaultColor, " MAKE BONDS NOW ! "); answerManager.setAnswerList(); yield break; }
/// <summary> /// Adds the vote. /// </summary> /// <param name="vote">The vote.</param> /// <param name="voteID">The vote ID.</param> /// <returns>True if it was OK, false otherwise</returns> public bool AddVote(XareuServices.Model.Vote.Vote vote, out long voteID) { voteID = 0; Linq.vote newVote = new vote(); try { newVote.vote_publication = vote.Publication.Id; newVote.vote_karma = vote.Karma; newVote.vote_author = vote.Author.Id; newVote.vote_positive = vote.Positive; data.votes.InsertOnSubmit(newVote); data.SubmitChanges(); voteID = this.getLastVoteID(); return(true); } catch { return(false); } }
private void yes() { if (v == vote.yes) { YesButton.FontWeight = FontWeights.Normal; YesButton.Background = Brushes.LightSlateGray; v = vote.none; //total-- } else { YesButton.FontWeight = FontWeights.ExtraBlack; YesButton.Background = Brushes.SpringGreen; NoButton.FontWeight = FontWeights.Normal; NoButton.Background = Brushes.LightSlateGray; v = vote.yes; //total++ } }
//constructor: method that makes itself public PhotoCard() { InitializeComponent(); this.ApplyTemplate(); this.Background = new SolidColorBrush(Colors.Transparent); this.ShowsActivationEffects = false; this.BorderBrush = System.Windows.Media.Brushes.Transparent; Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome ssc; ssc = this.Template.FindName("shadow", this) as Microsoft.Surface.Presentation.Generic.SurfaceShadowChrome; ssc.Visibility = Visibility.Hidden; FlipToBack = this.FindResource("sbFlip") as Storyboard; FlipToBack.Completed += new EventHandler(sbFlip_Completed); FlipToFront = this.FindResource("sbReverse") as Storyboard; FlipToFront.Completed += new EventHandler(sbReverse_Completed); _thumbnail = new Thumbnail(); _score = new List<string>(); this.Name = "copy"; v = vote.none; _thumbnail.MyPhotoCard = this; }
public override void onStartPhase() { // Fill out voting queue with other clients answers. answerManager.setVotingQueue(); onTransition(phaseState.on); uiManager.setPhaseCanvas(ref uiManager.Instance.votingCanvas, true); // animate and generate top and bottom answer for vote on screen onDisplayAnswer(vote.first,ref topAnswer, uiManager.Instance.votingAnswerTxt1.gameObject); onDisplayAnswer(vote.second, ref downAnswer, uiManager.Instance.votingAnswerTxt2.gameObject); topAnswer.getGObject().GetComponent<animationManager>().play("topAnswer"); downAnswer.getGObject().GetComponent<animationManager>().play("downAnswer"); uiManager.Instance.topVoteBtn.onClick.AddListener(() =>{ voteChoice = vote.first; onSubmit(); }); uiManager.Instance.downVoteBtn.onClick.AddListener(() => { voteChoice = vote.second; onSubmit(); }); }
private void no() { if (v == vote.no) { NoButton.FontWeight = FontWeights.Normal; NoButton.Background = Brushes.LightSlateGray; v = vote.none; //total ++ } else { NoButton.FontWeight = FontWeights.ExtraBlack; NoButton.Background = Brushes.Tomato; YesButton.FontWeight = FontWeights.Normal; YesButton.Background = Brushes.LightSlateGray; v = vote.no; //total -- } }