// Update the details of that barcode
        private void SubmitNewCode(object sender, RoutedEventArgs e)
        {
            if (this.nameInputBox.Text.Equals("") || this.quantityEntryBox.Text.Equals(""))
            {
                MessageBox.Show("Invalid Values Inputted");
                return;
            }

            try
            {
                int?        quantity       = Convert.ToInt32(this.quantityEntryBox.Text);
                BarcodeItem newBarcodeItem = AppContext.appContext.itemEdit;
                newBarcodeItem.quantity  = quantity;
                newBarcodeItem.itemTitle = this.nameInputBox.Text;

                AppContext.appContext.AddOrUpdate(newBarcodeItem);
                AppContext.appContext.StoreData();

                NavigationService.RemoveBackEntry();
                NavigationService.GoBack();
            }
            catch (System.FormatException)
            {
                MessageBox.Show("Invalid Quantity Value Inputted");
                return;
            }
        }
        // Delete the item
        public void DeleteBarcodeItem(BarcodeItem barcodeItem)
        {
            foreach (BarcodeItem temp in this.itemList)
            {
                if (temp.barcodeNumber.Equals(barcodeItem.barcodeNumber) && temp.barcodeType.Equals(barcodeItem.barcodeType))
                {
                    this.itemList.Remove(temp);
                    break;
                }
            }

            this.StoreData();
        }
        public BarcodeItem UpdateCurrentItem(BarcodeItem barcodeItem)
        {
            List <BarcodeItem> tempList = this.itemList;

            foreach (BarcodeItem temp in tempList)
            {
                if (temp.barcodeNumber.Equals(barcodeItem.barcodeNumber) && temp.barcodeType.Equals(barcodeItem.barcodeType))
                {
                    return(temp);
                }
            }
            // if not found we return what we were given
            return(barcodeItem);
        }
        // Add or update and item and then save it
        public void AddOrUpdate(BarcodeItem barcodeItem)
        {
            if (this.ContainsBarcode(barcodeItem.barcodeNumber, barcodeItem.barcodeType))
            {
                List <BarcodeItem> tempList = this.itemList;
                foreach (BarcodeItem temp in tempList)
                {
                    if (temp.barcodeNumber.Equals(barcodeItem.barcodeNumber) && temp.barcodeType.Equals(barcodeItem.barcodeType))
                    {
                        temp.itemTitle = barcodeItem.itemTitle;
                        temp.quantity  = barcodeItem.quantity;
                    }
                }
            }
            else
            {
                this.itemList.Add(barcodeItem);
            }

            this.StoreData();
        }
        //Set up the new card and wait for user input of go back.
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (loaded)
            {
                return;
            }
            this.loaded = true;
            if (AppContext.appContext.itemEdit != null)
            {
                this.barcodeNumber.Text = AppContext.appContext.itemEdit.barcodeNumber;
                this.barcodeType.Text   = AppContext.appContext.itemEdit.barcodeType;
                this.barcodeText        = this.barcodeNumber.Text;

                this.currentItem = new BarcodeItem(this.barcodeText, this.barcodeType.Text);

                this.GenerateBarcode();
                this.setUpSearchTaskUPC();

                if (this.barcodeType.Text.Contains("UPC") || this.barcodeType.Text.Contains("EAN"))
                {
                    this.GetProductInformation();
                    this.CheckBarcodeItem();
                }
                else
                {
                    this.setUpFailCode();
                }

                //update the currentItem against our memory
                this.currentItem = AppContext.appContext.UpdateCurrentItem(this.currentItem);
            }
            else
            {
                NavigationService.GoBack();
            }
        }