public void RemovePoll(Poll poll) { PollTable.Remove(poll); var votes = VoteTable.Where(x => x.Id == poll.Id).ToList(); VoteTable.RemoveRange(votes); SaveChanges(); }
public void AddPoll(int userId, string name) { PollTable.Insert(new Poll { Name = name, OwnerId = userId, IsSetUp = false, CanAddOptions = false }); }
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(); }
public bool DeletePoll(long pollId, int userId) { var targetPoll = GetPoll(pollId); if (targetPoll != null && userId == targetPoll.OwnerId) { return(PollTable.Delete(pollId)); } else { return(false); } }
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(); }
public void Update(Poll poll) { PollTable.Update(poll); }
public IEnumerable <Poll> GetPollsByUser(int userId) { return(PollTable.Find(poll => poll.OwnerId == userId)); }
public Poll GetPoll(long pollId) { return(PollTable.FindById(pollId)); }
public IEnumerable <Poll> GetPollsBy(long userId, long groupId) { return(PollTable.Where(x => x.UserId == userId && x.GroupId == groupId)); }
public Poll GetPoll(int pollId) { return(PollTable.Where(x => x.Id == pollId).FirstOrDefault()); }
public int AddPoll(Poll poll) { PollTable.Add(poll); SaveChanges(); return(poll.Id); }