Example #1
0
        public void RemovePoll(Poll poll)
        {
            PollTable.Remove(poll);
            var votes = VoteTable.Where(x => x.Id == poll.Id).ToList();

            VoteTable.RemoveRange(votes);
            SaveChanges();
        }
Example #2
0
 public void AddPoll(int userId, string name)
 {
     PollTable.Insert(new Poll
     {
         Name          = name,
         OwnerId       = userId,
         IsSetUp       = false,
         CanAddOptions = false
     });
 }
Example #3
0
        public void RemovePoll(int pollId)
        {
            var polls = PollTable.Where(x => x.Id == pollId).ToList();

            PollTable.RemoveRange(polls);
            var votes = VoteTable.Where(x => x.Id == pollId).ToList();

            VoteTable.RemoveRange(votes);
            SaveChanges();
        }
Example #4
0
        public bool DeletePoll(long pollId, int userId)
        {
            var targetPoll = GetPoll(pollId);

            if (targetPoll != null && userId == targetPoll.OwnerId)
            {
                return(PollTable.Delete(pollId));
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        public void UpdatePollMessageId(int pollId, long messageId)
        {
            Poll edit = PollTable.Find(pollId);

            if (edit != null)
            {
                edit.MessageId = messageId;
            }
            else
            {
                throw new NullReferenceException("Poll could not be found");
            }

            SaveChanges();
        }
Example #6
0
 public void Update(Poll poll)
 {
     PollTable.Update(poll);
 }
Example #7
0
 public IEnumerable <Poll> GetPollsByUser(int userId)
 {
     return(PollTable.Find(poll => poll.OwnerId == userId));
 }
Example #8
0
 public Poll GetPoll(long pollId)
 {
     return(PollTable.FindById(pollId));
 }
Example #9
0
 public IEnumerable <Poll> GetPollsBy(long userId, long groupId)
 {
     return(PollTable.Where(x => x.UserId == userId && x.GroupId == groupId));
 }
Example #10
0
 public Poll GetPoll(int pollId)
 {
     return(PollTable.Where(x => x.Id == pollId).FirstOrDefault());
 }
Example #11
0
 public int AddPoll(Poll poll)
 {
     PollTable.Add(poll);
     SaveChanges();
     return(poll.Id);
 }