コード例 #1
0
        public OrganizationModel(Organization organization, bool downloadEntityDates = true)
        {
            Organization = organization;
            if (downloadEntityDates)
            {
                List <Scientist> scientists = OrganizationService.GetScientists(Organization);
                foreach (Scientist s in scientists)
                {
                    Scientists.Add(new ScientistModel(s));
                }

                Scientists.CollectionChanged += (o, e) =>
                {
                    if (e.Action.ToString().Equals("Add"))
                    {
                        ScientistModel sm = null;
                        foreach (ScientistModel scm in e.NewItems)
                        {
                            sm = scm;
                        }
                        OrganizationService.AddScientist(Organization, sm.Scientist);
                    }
                    else if (e.Action.ToString().Equals("Remove"))
                    {
                        ScientistModel sm = null;
                        foreach (ScientistModel scm in e.OldItems)
                        {
                            sm = scm;
                        }
                        OrganizationService.RemoveScientist(Organization, sm.Scientist);
                    }
                    OnPropertyChanged("Scientists");
                };
            }
        }