public void AddItem(ItemViewModel newItem) { // add to collection Items.Add(newItem); // Add to database localDb.Items.InsertOnSubmit(newItem); // Save changes to database localDb.SubmitChanges(); }
public void DeleteItem(ItemViewModel itemForDelete) { // Remove from the collection Items.Remove(itemForDelete); using (localDb) { // Remove from the database if (localDb.DatabaseExists()) { localDb.Items.DeleteOnSubmit(itemForDelete); // Submit changes to database localDb.SubmitChanges(); } } }