public void AddEntry( Entry e ) { if ( !Entries.Any ( p => p.Title == e.Title ) ) { Entries.Add ( e ); isUnsavedChanges = true; } else { throw new ArgumentException ( "An entry with the title, '" + e.Title + "' already exists. Titles must be unique" ); } }
public void DeleteEntry( Entry e ) { // find first in case fields (other than Id) have been edited) Entry toDel = Entries.First<Entry> ( p => p.Id == e.Id ); Entries.Remove ( toDel ); }
public void UpdateEntry( Entry e ) { Entry existingEntry = Entries.FirstOrDefault ( p => p.Id == e.Id ); if ( existingEntry != null ) { existingEntry.Login = e.Login; existingEntry.Password = e.Password; existingEntry.Note = e.Note; isUnsavedChanges = true; } else { throw new ArgumentException ( "Cannot find an entry with the title, '" + e.Title + "'. Update Failed." ); } }