/// <summary> /// Move item to another list /// </summary> /// <param name="oldList">Instance of old item list</param> /// <param name="newList">Instance of new item list</param> /// <param name="listItem">Instance of item to be moved</param> public void MoveItemToAnotherList(ShoppingList oldList, ShoppingList newList, ShoppingListItem listItem) { oldList.ListItems.Remove(listItem); oldList.ModifiedDate = DateTime.Now; //Filter list items collection with adding new item to list oldList.FilterItemsCollection(); listItem.List = newList; newList.ListItems.Add(listItem); newList.ModifiedDate = DateTime.Now; //Filter list items collection with adding new item to list newList.FilterItemsCollection(); //Submiting all changes to database //listDB.ListItems.InsertOnSubmit(newListItem); listDB.SubmitChanges(); }
/// <summary> /// Adding new list item to list /// </summary> /// <param name="currentList">Instance of list to which add new item</param> /// <param name="newListItem">Instance of new item to be added</param> public void AddNewListItem(ShoppingList currentList, ShoppingListItem newListItem) { newListItem.CreatedDate = DateTime.Now; newListItem.ModifiedDate = DateTime.Now; currentList.ListItems.Add(newListItem); currentList.ModifiedDate = DateTime.Now; //Filter list items collection with adding new item to list currentList.FilterItemsCollection(); //Submiting all changes to database listDB.ListItems.InsertOnSubmit(newListItem); listDB.SubmitChanges(); }