internal StocDepozitContext() : base() { StocDepozitRepository = new StocDepozitRepository(); ListStocDepozit = new ObservableCollection <StocDepozit>(StocDepozitRepository.ListaStocDepozit); Summary = ListStocDepozit.Count + " entries."; ListStocDepozit.CollectionChanged += Borderou_CollectionChanged; }
private void Borderou_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { int newIndex = e.NewStartingIndex; StocDepozitRepository.AddNewRecord(ListStocDepozit[newIndex]); } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { List <StocDepozit> tempListOfRemovedItems = e.OldItems.OfType <StocDepozit>().ToList(); // ComenziRepository.DelRecord(tempListOfRemovedItems[0].Factura); } /*else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace) * { * List<Movie> tempListOfMovies = e.NewItems.OfType<Movie>().ToList(); * MovieRepository.UpdateRecord(tempListOfMovies[0]); // As the IDs are unique, only one row will be effected hence first index only * } */ }