public FoodGroupNodeViewModel( IDataRepository dataRepository, ICommand childClickCommand ) : base(DisplayStrings.AdminFoodGroupsTitle, dataRepository, childClickCommand) { _children = new ObservableCollection<TreeNodeViewModel>( (from foodGroup in dataRepository.GetAllFoodGroups() select new ClickableTreeNodeViewModel( foodGroup.Name, childClickCommand, foodGroup.ID )).ToList() ); Children = new ReadOnlyObservableCollection<TreeNodeViewModel>( _children ); }
public AllFoodGroupsViewModel( IDataRepository dataRepository ) { _foodGroups = new ObservableCollection<FoodGroup>( dataRepository.GetAllFoodGroups() ); Items = new ReadOnlyObservableCollection<FoodGroup>( _foodGroups ); _dataRepository = dataRepository; _dataRepository.ItemAdded += this.OnFoodGroupAdded; _dataRepository.ItemDeleted += this.OnFoodGroupRemoved; _dataRepository.ItemModified += this.OnFoodGroupModified; }