Ejemplo n.º 1
0
        void AttachCollections()
        {
            if (_participant.VaccineModelsAdministered == null)
            {
                _participant.VaccineModelsAdministered = Mapper.Map <List <VaccineAdministeredModel> >((from r in _repository.VaccinesAdministered
                                                                                                        where r.ParticipantId == _participant.Id
                                                                                                        select r).ToList());
            }
            if (_participant.StudyCentre == null)
            {
                _participant.StudyCentre = _repository.LocalStudyCentres.First(s => s.Id == _participant.CentreId);
            }
            if (VaccinesAdministered != null)
            {
                VaccinesAdministered.Clear(); // remove event handlers
            }
            else
            {
                VaccinesAdministered = new ObservableCollection <VaccineAdministeredViewModel>();
                VaccinesAdministered.CollectionChanged += VaccinesAdministered_CollectionChanged;
            }

            foreach (VaccineAdministeredModel model in _participant.VaccineModelsAdministered)
            {
                VaccineAdministeredViewModel vm = new VaccineAdministeredViewModel(model, AllVaccinesAvailable);
                VaccinesAdministered.Add(vm);
            }
            VaccinesAdministered.Add(NewVaccineAdministeredViewModel());
        }
Ejemplo n.º 2
0
        VaccineAdministeredViewModel NewVaccineAdministeredViewModel()
        {
            var returnVar = new VaccineAdministeredViewModel(
                new VaccineAdministeredModel
            {
                AdministeredTo = _participant
            }
                , AllVaccinesAvailable)
            {
                AllowEmptyRecord = true
            };

            returnVar.PropertyChanged += NewVaccineAdminVm_PropertyChanged;
            return(returnVar);
        }