private void ChangeStateRegister(FootballClub entity, IFootballClubConRepository repository) { entity.PropertyChanged += (sender, e) => { if (e.PropertyName != "State") { entity.State = repository.GetState(entity); } }; }
private void ListenerChangeState(ObservableCollection <FootballClub> data, IFootballClubConRepository repository) { data.ToList().ForEach(a => ChangeStateRegister(a, repository)); data.CollectionChanged += (sender, e) => { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { var entity = e.NewItems[0] as FootballClub; entity.State = "Added"; } }; }
//public MainViewModel(IConGenericRepository<FootballClub> repository) public MainViewModel(IFootballClubConRepository repository) { ////if (IsInDesignMode) ////{ //// // Code runs in Blend --> create design time data. ////} ////else ////{ //// // Code runs "for real" ////} _repository = repository; Data = _repository.All(); ListenerChangeState(Data, _repository); }