public MealTemplateNodeViewModel( IDataRepository dataRepository, ICommand childClickCommand ) : base(DisplayStrings.AdminMealTemplatesTitle, dataRepository, childClickCommand) { _children = new ObservableCollection<TreeNodeViewModel>( (from mealTemplate in dataRepository.GetAllMealTemplates() select new ClickableTreeNodeViewModel( mealTemplate.Name, childClickCommand, mealTemplate.ID )).ToList() ); Children = new ReadOnlyObservableCollection<TreeNodeViewModel>( _children ); }
public AllMealTemplatesViewModel( IDataRepository dataRepository ) { _dataRepository = dataRepository; _dataRepository.ItemAdded += this.OnMealTemplateAdded; _dataRepository.ItemDeleted += this.OnMealTemplateRemoved; _dataRepository.ItemModified += this.OnMealTemplateModified; _mealTemplates = new ObservableCollection<MealTemplate>( dataRepository.GetAllMealTemplates() ); Items = new ReadOnlyObservableCollection<MealTemplate>( _mealTemplates ); }