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"); }; } }
public ConferenceModel(Conference conference, bool downloadEntityDates = true) { Conference = conference; if (downloadEntityDates) { List <Scientist> scientists = ConferenceService.GetScientists(Conference); 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; } ConferenceService.AddScientist(Conference, sm.Scientist); } else if (e.Action.ToString().Equals("Remove")) { ScientistModel sm = null; foreach (ScientistModel scm in e.OldItems) { sm = scm; } ConferenceService.RemoveScientist(Conference, sm.Scientist); } }; List <Report> reports = ConferenceService.GetReportsOnConference(Conference); foreach (Report r in reports) { Reports.Add(new ReportModel(r)); } Reports.CollectionChanged += (o, e) => { if (e.Action.ToString().Equals("Add")) { ReportModel rm = null; foreach (ReportModel rtm in e.NewItems) { rm = rtm; } ConferenceService.AddReport(Conference, rm.Report); } else if (e.Action.ToString().Equals("Remove")) { ReportModel rm = null; foreach (ReportModel rtm in e.OldItems) { rm = rtm; } ConferenceService.RemoveReport(Conference, rm.Report); } }; } }