public void Add(tv_MonthFishingViewModel month) { base.Children.Add(month); }
public void Refresh(EditedEntity editedEnity) { bool breakAll = false; Boolean itemFound = false; switch (editedEnity.BSCEntity.GetType().Name) { case "ProjectSetting": ProjectSetting editedProjectSetting = (ProjectSetting)editedEnity.BSCEntity; foreach (TreeViewItemViewModel tvi in treeView.Items) { tv_ProjectSettingViewModel psvm = (tv_ProjectSettingViewModel)tvi; if (psvm._projectSetting.ProjectID == editedProjectSetting.ProjectID) { itemFound = true; if (editedEnity.EditAction == EditAction.Delete) { } else if (editedEnity.EditAction == EditAction.Update) { psvm.Edit(editedProjectSetting); } break; } } if (!itemFound && editedEnity.EditAction == EditAction.Add) { _bscViewModel.Add(editedProjectSetting); } treeView.Items.Refresh(); break; case "Sampling": Sampling sampling = (Sampling)editedEnity.BSCEntity; if (editedEnity.EditAction == EditAction.Add) { foreach (TreeViewItemViewModel projectItem in treeView.Items) { if (projectItem.IsExpanded) { foreach (TreeViewItemViewModel landingSiteItem in projectItem.Children) { if (sampling.LandingSite.LandingSiteID == ((tv_LandingSiteViewModel)landingSiteItem)._landingSite.LandingSiteID) { itemFound = true; if (landingSiteItem.IsExpanded) { itemFound = false; foreach (TreeViewItemViewModel gearItem in landingSiteItem.Children) { if (((tv_GearViewModel)gearItem)._gear.GearName == sampling.Gear.GearName) { itemFound = true; if (gearItem.IsExpanded) { itemFound = false; foreach (TreeViewItemViewModel monthItem in gearItem.Children) { tv_MonthFishingViewModel month = (tv_MonthFishingViewModel)monthItem; if (month.MonthName == sampling.DateTimeSampled.ToString("MMM-yyyy")) { itemFound = true; breakAll = true; break; } } //month not found in gear if (!itemFound && editedEnity.EditAction == EditAction.Add) { ((tv_GearViewModel)gearItem).Refresh(); itemFound = true; breakAll = true; break; } } } } //gear was not found under landing site if (!itemFound && editedEnity.EditAction == EditAction.Add) { ((tv_LandingSiteViewModel)landingSiteItem).Add(sampling.Gear); breakAll = true; itemFound = true; break; } } } } //landing site was not found under project in the tree if (!itemFound) { ((tv_ProjectSettingViewModel)projectItem).Add(sampling.LandingSite); itemFound = true; breakAll = true; break; } } if (breakAll) { break; } } } break; } }