Example #1
0
        private static StringBuilder ExtractKeywords(PossibleAnswer answer)
        {
            StringBuilder keywords = new StringBuilder();

            AddTextToKeywords(keywords, answer.text);

            return(keywords);
        }
        /// <summary>
        /// Create a new PossibleAnswer object.
        /// </summary>
        /// <param name="id">Initial value of the id property.</param>
        /// <param name="pollId">Initial value of the PollId property.</param>
        /// <param name="text">Initial value of the text property.</param>
        /// <param name="votesCount">Initial value of the VotesCount property.</param>
        public static PossibleAnswer CreatePossibleAnswer(global::System.Int32 id, global::System.Int32 pollId, global::System.String text, global::System.Int32 votesCount)
        {
            PossibleAnswer possibleAnswer = new PossibleAnswer();

            possibleAnswer.id         = id;
            possibleAnswer.PollId     = pollId;
            possibleAnswer.text       = text;
            possibleAnswer.VotesCount = votesCount;
            return(possibleAnswer);
        }
Example #3
0
        public static void AddVote(int answerId, string voterIp)
        {
            JustPollsEntities database = new JustPollsEntities();

            int oldVotesCount = (from p in database.Votes where p.answerId == answerId && p.voterIp == voterIp select p).Count();

            PossibleAnswer answer = (from p in database.PossibleAnswers where p.id == answerId select p).FirstOrDefault();

            if (oldVotesCount == 0 && answer != null)
            {
                answer.VotesCount++;

                Vote newVote = new Vote();
                newVote.answerId = answerId;
                newVote.Date     = DateTime.Now;
                newVote.voterIp  = voterIp;

                database.Votes.AddObject(newVote);
                database.SaveChanges();
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the PossibleAnswers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPossibleAnswers(PossibleAnswer possibleAnswer)
 {
     base.AddObject("PossibleAnswers", possibleAnswer);
 }