public OrganizationAddsScientistViewModel(Window window, OrganizationModel organization) { List <Scientist> scientists = ScientistService.GetScientists(); foreach (Scientist s in scientists) { Scientists.Add(new ScientistModel(s)); } this.Window = window; this.SelectedOrganization = organization; }
public ConferenceAddsScientistViewModel(Window window, ConferenceModel conference) { List <Scientist> scientists = ScientistService.GetScientists(); foreach (Scientist s in scientists) { Scientists.Add(new ScientistModel(s)); } this.Window = window; this.SelectedConference = conference; }
public CountryAddsScientistViewModel(Window window, CountryModel selectedCountry) { List <Scientist> scientists = ScientistService.GetScientists(); foreach (Scientist s in scientists) { Scientists.Add(new ScientistModel(s)); } this.Window = window; this.SelectedCountry = selectedCountry; }
public ScientistModel(Scientist scientist, bool downloadEntityDates = true) { Scientist = scientist; if (downloadEntityDates) { List <Conference> conferences = ScientistService.GetConferences(Scientist); foreach (Conference c in conferences) { Conferences.Add(new ConferenceModel(c, false)); } foreach (Report r in Scientist.Reports) { Reports.Add(new ReportModel(r)); } List <Organization> organizations = ScientistService.GetOrganizations(Scientist); foreach (Organization o in organizations) { Organizations.Add(new OrganizationModel(o, false)); } } Conferences.CollectionChanged += (o, e) => { if (e.Action.ToString().Equals("Add")) { ConferenceModel cm = null; foreach (ConferenceModel cmo in e.NewItems) { cm = cmo; } ScientistService.AddConference(Scientist, cm.Conference); } else if (e.Action.ToString().Equals("Remove")) { ConferenceModel cm = null; foreach (ConferenceModel cmo in e.OldItems) { cm = cmo; } ScientistService.RemoveConference(Scientist, cm.Conference); } OnPropertyChanged("Conferences"); }; Reports.CollectionChanged += (o, e) => { if (e.Action.ToString().Equals("Add")) { ReportModel rm = null; foreach (ReportModel rem in e.NewItems) { rm = rem; } ScientistService.AddReport(Scientist, rm.Report); } else if (e.Action.ToString().Equals("Remove")) { ReportModel rm = null; foreach (ReportModel rem in e.OldItems) { rm = rem; } ScientistService.RemoveReport(Scientist, rm.Report); } OnPropertyChanged("Reports"); OnPropertyChanged("ReportsCount"); }; Organizations.CollectionChanged += (o, e) => { if (e.Action.ToString().Equals("Add")) { OrganizationModel om = null; foreach (OrganizationModel orm in e.NewItems) { om = orm; } ScientistService.AddOrganization(Scientist, om.Organization); } else if (e.Action.ToString().Equals("Remove")) { OrganizationModel om = null; foreach (OrganizationModel orm in e.OldItems) { om = orm; } ScientistService.RemoveOrganization(Scientist, om.Organization); } OnPropertyChanged("Organizations"); }; }