private void Falls_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { //הוספה CurrentModel.AddFall(e.NewItems[0] as Fall); PredictionAndRealFalls.AddFall(e.NewItems[0] as Fall); } if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { //הסרה var oldId = (e.OldItems[0] as Fall).FallId; CurrentModel.Remove(oldId); } }
private void Assessment_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { //add CurrentModel.Add(e.NewItems[0] as Assessment); PredictionAndRealFalls.AddAssessment(e.NewItems[0] as Location_); //???? } if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { //remove var oldId = (e.OldItems[0] as Assessment).id; CurrentModel.Remove(oldId); } }
private void Falls_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { // Insertion CurrentModel.db.falls.Add(e.NewItems[0] as Fall); CurrentModel.db.SaveChanges(); } if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { // Deletion Fall toRem = e.OldItems[0] as Fall; try { CurrentModel.Remove(toRem.id); CurrentModel.db.SaveChanges(); } catch (Exception) { } // Just in Case } }