Esempio 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());
        }
Esempio n. 2
0
 private void NewVaccineAdminVm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "AdministeredAtDate" || e.PropertyName == "AdministeredAtTime" || e.PropertyName == "SelectedVaccine")
     {
         var newVaccineAdminVm = (VaccineAdministeredViewModel)sender;
         newVaccineAdminVm.AllowEmptyRecord = newVaccineAdminVm.IsEmpty;
         if (!newVaccineAdminVm.IsEmpty && newVaccineAdminVm.IsValid())
         {
             newVaccineAdminVm.AllowEmptyRecord = false;
             _participant.VaccineModelsAdministered.Add(newVaccineAdminVm.VaccineAdministeredModel);
             newVaccineAdminVm.PropertyChanged -= NewVaccineAdminVm_PropertyChanged;
             VaccinesAdministered.Add(NewVaccineAdministeredViewModel());
         }
     }
 }
Esempio n. 3
0
 bool CanSave(object param)
 {
     return((IsParticipantModelChanged && WasValidOnLastNotify) || (IsVaccineAdminChanged && VaccinesAdministered.All(v => v.IsValid())));
 }