public ParticipantFieldViewModel(Poll poll)
 {
     var participantRepository = new ParticipantRepository(NHibernateHelper.GetCurrentSession());
     var fieldsTemplateRepository = new FieldsTemplateRepository(NHibernateHelper.GetCurrentSession());
     this.poll = poll;
     if (poll.isGroup == false)
         this.fieldValues = participantRepository.GetParticipantValuesByPollID(poll.pollID).OrderBy(first=>first["Device ID"])
             .OrderBy(first => first["First Name"]).OrderBy(first => first["Last Name"]).ToList();
     else
     {
         this.fieldValues = participantRepository.GetGroupValuesByPollID(poll.pollID).OrderBy(first => first["Name"]).ToList();
         hasdem = new List<bool>();
         hascom = new List<bool>();
         foreach (ParticipantField f in poll.participantFields)
         {
             hasdem.Add(poll.questions.Where
                 (q => q.type == QuestionType.Demographic)
                 .Cast<DemographicQuestion>().Any(p => p.linkedField != null
                     && p.linkedField.fieldID == f.fieldID));
             hascom.Add(poll.questions.Where(q => q.type == QuestionType.Demographic)
                 .Cast<DemographicQuestion>().Any(p => p.linkedField != null
                     && p.linkedField.fieldID == f.fieldID && p.compareWith != null));
         }
     }
     entities = getChildEntites();
     this.selectedTemplateID = -1;
     this.templates = fieldsTemplateRepository.GetFieldsTemplates();
     this.hasdems = poll.questions.Where
             (q => q.type == QuestionType.Demographic)
             .Cast<DemographicQuestion>().Any(p => p.linkedField != null);
     this.hasCompare = poll.questions.Where
             (q => q.type == QuestionType.Demographic)
             .Cast<DemographicQuestion>().Any(p => p.linkedField != null && p.compareWith != null);
 }
 public DetailsViewModel(int participantID, int pollID)
 {
     var pollRepository = new PollRepository(NHibernateHelper.GetCurrentSession());
     var participantRepository = new ParticipantRepository(NHibernateHelper.GetCurrentSession());
     this.poll = pollRepository.GetPollByID(pollID);
     Dictionary<Participant, Dictionary<String, String>> groupies = new Dictionary<Participant, Dictionary<String, String>>();
     if (poll.isGroup)
     {
         foreach (Participant participant in participantRepository.GetParticipantsOfGroup(participantRepository.GetGroupByGroupID(participantID), poll))
             groupies.Add(participant,participantRepository.GetParticipantDetailsByParticipantID(participant.participantID,pollID));
         participants = groupies;
         this.group = participantRepository.GetGroupByGroupID(participantID);
     }
     else this.fieldValues = participantRepository.GetParticipantDetailsByParticipantID(participantID,pollID);
 }
 public ApplicationController(ISession session)
 {
     this.session = session;
     this.transaction = session.BeginTransaction();
     this.clientCodeRepository = new ClientCodeRepository(session);
     this.entityRepository = new EntityRepository(session);
     this.fieldsTemplateRepository = new FieldsTemplateRepository(session);
     this.messageRepository = new MessageRepository(session);
     this.participantRepository = new ParticipantRepository(session);
     this.pollRepository = new PollRepository(session);
     this.questionRepository = new QuestionRepository(session);
     this.reportRepository = new ReportRepository(session);
     this.responseRepository = new ResponseRepository(session);
     this.roleRepository = new RoleRepository(session);
     this.templateRepository = new TemplateRepository(session);
     this.userRepository = new UserRepository(session);
 }