void GetAllParticipants() { /* * var participantVMs = Array.ConvertAll(_repository.Participants.ToArray(), * new Converter<Participant, ParticipantListItemViewModel>(p => new ParticipantListItemViewModel(Mapper.Map<ParticipantModel>(p)))); * */ var now = DateTime.Now; int partCount = _repository.Participants.Count(); List <ParticipantListItemViewModel> participantVMs = new List <ParticipantListItemViewModel>(partCount); foreach (var p in _repository.Participants//.Include("VaccinesAdministered").Include("ProtocolViolations").OrderByDescending(dp => dp.Id) .Select(GetParticipantBaseMapExpression())) { p.StudyCentre = _repository.FindStudyCentre(p.CentreId); p.AgeDays = (now - p.DateTimeBirth).Days; var newVm = new ParticipantListItemViewModel(p); participantVMs.Add(newVm); } _ageUpdater = AgeUpdatingMediator.GetService(participants: (from p in participantVMs where p.IsKnownDead != true && p.AgeDays <= ParticipantBaseModel.FollowToAge select(IBirthday) p), capacity: partCount); _ageUpdater.OnAgeIncrement += OnNewAge; AllParticipants = new ListCollectionView(participantVMs) { CustomSort = new ParticipantIdSortDesc() }; _groupByDataRequired = true; _selectedDataRequired = (DataRequiredOption[])Enum.GetValues(typeof(DataRequiredOption)); _selectedCentres = _repository.GetCentresRequiringData(); SetGrouping(); //creating dispatchertimer so that screen is rendered before setting up the birthtime updating algorithms }
public DataSummaryViewModel(IRepository repository) : base(repository) { _participantData = _repository.GetParticipantSummary(); ParticipantData = new ParticipantSummaryViewModel(_participantData); ScreenedPatientData = _repository.GetScreenedPatientSummary(); _repository.ParticipantAdded += _repository_ParticipantAdded; _repository.ParticipantUpdated += _repository_ParticipantUpdated; _repository.ScreenedPatientAdded += _repository_ScreenedPatientAdded; _repository.ProtocolViolationAddOrUpdate += _repository_ProtocolViolationAddOrUpdate; _ageService = AgeUpdatingMediator.GetService(repository); _ageService.OnAgeIncrement += OnNewAge; }