private void FisherCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { TypeOfChange c = TypeOfChange.Added; EditSuccess = false; switch (e.Action) { case NotifyCollectionChangedAction.Add: { int newIndex = e.NewStartingIndex; Fisher newFisher = FisherCollection[newIndex]; if (Fishers.Add(newFisher)) { CurrentEntity = newFisher; EditSuccess = true; } } break; case NotifyCollectionChangedAction.Remove: { List <Fisher> tempListOfRemovedItems = e.OldItems.OfType <Fisher>().ToList(); if (Fishers.Delete(tempListOfRemovedItems[0])) { EditSuccess = true; CurrentEntity = null; } c = TypeOfChange.Deleted; } break; case NotifyCollectionChangedAction.Replace: { List <Fisher> tempList = e.NewItems.OfType <Fisher>().ToList(); if (Fishers.Update(tempList[0])) { EditSuccess = true; CurrentEntity = tempList[0]; } c = TypeOfChange.Edited; } break; } if (EditSuccess && EntitiesChanged != null) { EntitiesChangedEventArg ece = new EntitiesChangedEventArg { TypeOfChange = c, Entity = CurrentEntity }; EntitiesChanged(this, ece); } }
public int NextRecordNumber() { int rv; if (FisherCollection.Count == 0) { rv = 1; } else { rv = Fishers.MaxRecordNumber() + 1;; } return(rv); }