public IList<Poll> GetPollsMasteredBy(User user) { var polls = (from item in session.Query<Poll>() where item.pollMasters.Contains(user) select item).ToList(); return polls; }
public Message(String message, User recipient) { this.messageID = -1; this.message = message; this.recipients = new List<User>(); this.recipients.Add(recipient); this.timeSent = DateTime.Now; }
public IDictionary<String, String> GetLatestMessages(int pollID, User recipient) { var messages = (from m in session.Query<Message>() from p in session.Query<Poll>() where m.recipients.Contains(recipient) && p.pollID == pollID && p.messages.Contains(m) orderby m.timeSent descending select m); return messages.ToDictionary(m => m.messageID.ToString(), m => m.message); }
public static Boolean CanAddQuestion(User user, Poll poll) { foreach (var item in user.CreatedPolls) { if (item == poll) { return true; } } return false; }
public Participant(String deviceID, ParticipantType type, User linkedUser, String firstName, String lastName) { this.participantID = -1; this.deviceID = deviceID; this.type = type; this.group = null; this.linkedUser = linkedUser; this.attended = false; this.firstName = firstName; this.lastName = lastName; this.isTestParticipant = false; this.entity = null; this.votingWeight = 1; }
public static ICollection<Role> GetRolesForPole(User user, Poll poll) { var roles = new HashSet<Role>(); if (user.ManagedPolls.Contains(poll)) { roles.Add(new Role("Poll Administrator")); } if (user.CreatedPolls.Contains(poll)) { roles.Add(new Role("Poll Creator")); } if (poll.pollMasters.Contains(user)) { roles.Add(new Role("Poll Master")); } return roles; }
public static Boolean CanEditQuestion(User user, Poll poll, Question question) { if (poll.isTestPoll) { return true; } if (question == null) { if (user.Roles.Contains(new Role("Poll Master"))) { return true; } else { return false; } } foreach (var managedPoll in user.ManagedPolls) { if (managedPoll.questions.Contains(question)) { return true; } } foreach (var createdPoll in user.CreatedPolls) { if (createdPoll.questions.Contains(question)) { return true; } } if (poll.pollMasters.Contains(user)) { return true; } return false; }
public void Update(User user) { session.SaveOrUpdate(user); }
public void Add(User user) { session.Save(user); }
public IList<Participant> GetParticipantsByLinkedUser(User linkedUser) { var participants = (from item in session.Query<Participant>() where item.linkedUser.UserName == linkedUser.UserName select item).ToList(); return participants; }
public Participant GetParticipantByLinkedUserAndPoll(User linkedUser, Poll poll) { var participant = poll.participants.FirstOrDefault(p => p.linkedUser!=null && p.linkedUser.UserName.Equals(linkedUser.UserName)); return participant; }
public Participant GetParticipantByLinkedUser(User linkedUser) { var participant = (from item in session.Query<Participant>() where item.linkedUser.UserName == linkedUser.UserName select item).FirstOrDefault(); return participant; }
public Participant(int participantID, String deviceID, ParticipantType type, ParticipantGroup group, User linkedUser, Boolean attended, String firstName, String lastName) { this.participantID = participantID; this.deviceID = deviceID; this.type = type; this.group = group; this.linkedUser = linkedUser; this.attended = attended; this.firstName = firstName; this.lastName = lastName; this.isTestParticipant = false; this.entity = null; this.votingWeight = 1; }
public ClientCode(User owner) { this.Code = -1; this.Owner = owner; }