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

            VoteTable.RemoveRange(votes);
            SaveChanges();
        }
示例#2
0
 public void AddPoll(int userId, string name)
 {
     PollTable.Insert(new Poll
     {
         Name          = name,
         OwnerId       = userId,
         IsSetUp       = false,
         CanAddOptions = false
     });
 }
示例#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();
        }
示例#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);
            }
        }
示例#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();
        }
示例#6
0
 public void Update(Poll poll)
 {
     PollTable.Update(poll);
 }
示例#7
0
 public IEnumerable <Poll> GetPollsByUser(int userId)
 {
     return(PollTable.Find(poll => poll.OwnerId == userId));
 }
示例#8
0
 public Poll GetPoll(long pollId)
 {
     return(PollTable.FindById(pollId));
 }
示例#9
0
 public IEnumerable <Poll> GetPollsBy(long userId, long groupId)
 {
     return(PollTable.Where(x => x.UserId == userId && x.GroupId == groupId));
 }
示例#10
0
 public Poll GetPoll(int pollId)
 {
     return(PollTable.Where(x => x.Id == pollId).FirstOrDefault());
 }
示例#11
0
 public int AddPoll(Poll poll)
 {
     PollTable.Add(poll);
     SaveChanges();
     return(poll.Id);
 }