Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
 public void UpdateListFilterStore(ShoppingList list, string filterStore)
 {
     list.FilterStore = filterStore;
     listDB.SubmitChanges();
 }
 public void UpdateListFilterTag(ShoppingList list, string filterTag)
 {
     list.FilterTag = filterTag;
     listDB.SubmitChanges();
 }
        /// <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>
 /// Rename list
 /// </summary>
 /// <param name="renameList">List to be renamed</param>
 /// <param name="newName">New list name</param>
 public void RenameList(ShoppingList renameList, string newName)
 {
     //Select corresponding list in data context collection and changing its name
     var listInDB = listDB.Lists.Where(c => c.ListID == renameList.ListID).FirstOrDefault();
     listInDB.ListName = newName;
     listInDB.ModifiedDate = DateTime.Now;
     //Submiting all changes to database
     listDB.SubmitChanges();
 }
        /// <summary>
        /// Change item status. If status was 'Unchecked' -> change to 'Checked',
        /// else if status was 'Checked' -> change to 'Unchecked'
        /// </summary>
        /// <param name="currentList">Instance of list containing item to be changed</param>
        /// <param name="item">Instance of item to be updated</param>
        public void ChangeItemStatus(ShoppingList currentList, ShoppingListItem item)
        {
            ShoppingListItem itemInDB = listDB.ListItems.Where(i => i.ItemID == item.ItemID).FirstOrDefault();
            if (itemInDB.Status == 0)
                itemInDB.Status = 1;
            else
                itemInDB.Status = 0;
            itemInDB.ModifiedDate = DateTime.Now;
            currentList.ModifiedDate = DateTime.Now;
            currentList.SortItemsCollection();

            listDB.SubmitChanges();
        }
 /// <summary>
 /// Delete list from database
 /// </summary>
 /// <param name="delList">List to be deleted</param>
 public void DeleteList(ShoppingList delList)
 {
     listDB.Lists.DeleteOnSubmit(delList);
     listDB.SubmitChanges();
     //Delete list from current loaded collection
     ShoppingLists.Remove(delList);
 }
        /// <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();
        }
        /// <summary>
        /// Add new store to list
        /// </summary>
        /// <param name="list">Instance of list in which store will be added</param>
        /// <param name="store">Instance of store to be added</param>
        public void AddNewStore(ShoppingList list, ShoppingListStore store)
        {
            list.ListStores.Add(store);
            list.ModifiedDate = DateTime.Now;
            store.CreatedDate = DateTime.Now;
            store.ModifiedDate = DateTime.Now;

            listDB.ListStores.InsertOnSubmit(store);
            list.UpdateListStoreLabels();
            listDB.SubmitChanges();
        }
        /// <summary>
        /// Adding new list to collection and save it to local database
        /// </summary>
        /// <param name="newList">Instance of new adding list</param>
        public void AddNewList(ShoppingList newList)
        {
            //Initialisation list fields associated with date
            newList.CreatedDate = DateTime.Now;
            newList.ModifiedDate = DateTime.Now;

            //Insetrion and submition all changes to database
            listDB.Lists.InsertOnSubmit(newList);
            listDB.SubmitChanges();
            //Adding new list to current observable collection
            ShoppingLists.Add(newList);
        }
        /// <summary>
        /// Activate List Selector Control
        /// </summary>
        public void ActivateListSelector(ShoppingList list, ShoppingListItem item)
        {
            this.listSelector = new ListSelectorControl();
            listSelector.list = list;
            listSelector.item = item;
            listSelector.CollapsedVisualState.Storyboard.Completed +=new EventHandler(ListSelect_Completed);

            //Actually activating the dialog
            LayoutRoot.Children.Add(listSelector);
            listSelector.Activate();
            ApplicationBar.IsVisible = false;
        }
 /// <summary>
 /// Set shopping list selected - currently displaying on the MainPage of application
 /// </summary>
 /// <param name="list">ShoppingList instance, which have to be selceted
 ///  (currently displaying on the screen).</param>
 private void SetSelectedList(ShoppingList list)
 {
     DependencyObject listContainer = LayoutRoot.Children[0];
     Grid grid = VisualTreeHelper.GetChild(listContainer, 0) as Grid;
     UIElement obj = grid.Children[0] as ItemsControl;
     if (obj is Pivot)
         (obj as Pivot).SelectedItem = list;
     else if (obj is ListPicker)
         (obj as ListPicker).SelectedItem = list;
     else
         throw new Exception("Unrecognized control in the page's layout");
 }
        /// <summary>
        /// Creating message body string from current list's entries
        /// </summary>
        /// <param name="currentList">Instance of the selected current shopping list</param>
        /// <returns>String body of the selected current shopping list</returns>
        private string CreateMessageBody(ShoppingList currentList)
        {
            String body = String.Empty;

            if (currentList != null)
            {
                foreach (ShoppingListItem item in currentList.ListItems)
                {
                    if (item.Status <= 1)
                    {
                        body += String.Format("[{0}] ", item.Status == 0 ? " " : "X");
                        body += item.Quantity == null ? "" : item.Quantity + " ";
                        body += item.Units == null ? "" : item.Units + " ";
                        body += String.Format("{0} ", item.ItemName);

                        if (item.Tag != string.Empty || item.Price != 0.00F)
                        {
                            body += "()";
                            body = body.Insert(body.Length - 1, item.Tag == string.Empty ? "" : item.Tag + " ");
                            body = body.Insert(body.Length - 1, item.Price == 0.00F ? "" : String.Format("{0:F2}", item.Price));
                        }
                        body += "\n";
                    }
                }
            }
            return body;
        }
        //With EditNameGialog 'ok' button click will check 'new list name' TextBox
        void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            //Is 'new list name' TextBox.Text Empty?
            if (editNameDlg.DialogData.Text.Trim() != String.Empty)
            {
                //If 'new list name' TextBox.Text is NOT empty,
                //than create the collection of exist shopping list's names.
                //This collection will be checked for containing the 'new list name'.
                var listsNames = from ShoppingList list in App.ViewModel.ShoppingLists
                                 select list.ListName;
                string newListName = editNameDlg.DialogData.Text.Trim();

                //If 'new list name' already exist in this collection,
                //than it will be selected (currently displaying) the list with this name.
                if (listsNames.Contains(newListName))
                {
                    ShoppingList list = App.ViewModel.ShoppingLists.FirstOrDefault(x => x.ListName == newListName);
                    this.SetSelectedList(list);
                    editNameDlg.Deactivate();
                }
                //If 'new list name' DOES NOT exist in this collection,
                //than it will be renaming or adding new shopping list (accordingly to the EditNameDialogMode)
                else
                {
                    //Renaming exeisting shopping list and deactivating the control
                    if (editNameDlg.DialogMode == (int)EditNameDialog.EditNameDialogMode.RenamingList)
                    {
                        ShoppingList renameList = this.GetCurrentShoppingList();
                        App.ViewModel.RenameList(renameList, newListName);
                        editNameDlg.Deactivate();
                    }
                    //Adding new shopping list and deactivating the control
                    else if (editNameDlg.DialogMode == (int)EditNameDialog.EditNameDialogMode.AddingNewList)
                    {
                        ShoppingList newList = new ShoppingList() { ListName = newListName };
                        App.ViewModel.AddNewList(newList);
                        this.SetSelectedList(newList);
                        editNameDlg.Deactivate();
                    }
                }
            }
            //If 'new list name' TextBox.Text IS empty -> MessageBox for informating user
            //to input correct data.
            else
                MessageBox.Show("Please, input correct list's name" + "\n\n" +
                                "*Note: Name must not be empty", "Information", MessageBoxButton.OK);
        }