Ejemplo n.º 1
0
 public static void DeletePoll(int pollID)
 {
     PollSystemEntities context = new PollSystemEntities();
     context.ExecuteStoreCommand("DELETE FROM PollAnswers WHERE PollID={0}", pollID);
     context.ExecuteStoreCommand("DELETE FROM Polls WHERE PollID={0}", pollID);
 }
Ejemplo n.º 2
0
 public static void ResetPoll(int pollID)
 {
     PollSystemEntities context = new PollSystemEntities();
     context.ExecuteStoreCommand("UPDATE PollAnswers SET Votes=0 WHERE PollID={0}", pollID);
 }
Ejemplo n.º 3
0
 private static void CreateAnswer(string answerText, Poll newPoll)
 {
     using (PollSystemEntities context = new PollSystemEntities())
     {
         if (answerText.Length > 255)
         {
             // Special case: long text should be inserted directly
             string cmd = String.Format("INSERT INTO PollAnswers(Answer, Votes, PollID) VALUES ('{0}', {1}, {2})", answerText, 0, newPoll.PollID);
             context.ExecuteStoreCommand(cmd);
         }
         else
         {
             PollAnswer answer = new PollAnswer();
             answer.Answer = answerText;
             answer.PollID = newPoll.PollID;
             answer.Votes = 0;
             context.PollAnswers.AddObject(answer);
         }
         context.SaveChanges();
     }
 }