Example #1
0
        void ReleaseDesignerOutlets()
        {
            if (BtnAddToCart != null)
            {
                BtnAddToCart.Dispose();
                BtnAddToCart = null;
            }

            if (itemImage != null)
            {
                itemImage.Dispose();
                itemImage = null;
            }

            if (LblItemName != null)
            {
                LblItemName.Dispose();
                LblItemName = null;
            }

            if (LblSelectedQuantity != null)
            {
                LblSelectedQuantity.Dispose();
                LblSelectedQuantity = null;
            }

            if (LblSelectedSize != null)
            {
                LblSelectedSize.Dispose();
                LblSelectedSize = null;
            }

            if (LblTotal != null)
            {
                LblTotal.Dispose();
                LblTotal = null;
            }

            if (QuantityPicker != null)
            {
                QuantityPicker.Dispose();
                QuantityPicker = null;
            }

            if (SizePicker != null)
            {
                SizePicker.Dispose();
                SizePicker = null;
            }

            if (TxtItemDesc != null)
            {
                TxtItemDesc.Dispose();
                TxtItemDesc = null;
            }
        }
        /// <summary>
        /// Checks if the cart already has items
        /// </summary>
        private async Task ItemAlreadyInCart(ItemSize item)
        {
            CartItem queryCartItem = new CartItem
            {
                ITEM_TYPE_ID = item.ITEM_TYPE_ID,
                ITEM_SIZE    = item.ITEM_TYPE_SIZE,
                USER_ID      = _userId
            };


            if (!_itemExists)
            {
                var cartItem = await _restActions.ItemAlreadyInCart(queryCartItem);

                if (cartItem != null)
                {
                    _itemExists = true;

                    _cartItemId       = cartItem.CART_ITEM_ID;
                    _selectedQuantity = cartItem.QUANTITY;
                    _itemPrice        = cartItem.ITEM_PRICE;
                    _itemTypeId       = cartItem.ITEM_TYPE_ID;
                    //compute the cost
                    _itemsSubTotal = _itemPrice * _selectedQuantity;

                    //totalCost.Text = String.Format("{0:C}", totalItemCost);//totalItemCost.ToString();
                    LblTotal.Text = _itemsSubTotal.ToString("C", CultureInfo.CreateSpecificCulture("en-US"));

                    // _selectedSize = cartItems.ITEM_SIZE;
                    // sizeValue.Text = _selectedSize;

                    LblSelectedQuantity.Text = cartItem.QUANTITY.ToString();
                    QuantityPicker.Value     = _selectedQuantity;

                    BtnAddToCart.SetTitle("Update Cart", UIControlState.Highlighted);
                }
                else
                {
                    BtnAddToCart.SetTitle("Add to Cart", UIControlState.Normal);
                }
            }
            else
            {
                BtnAddToCart.SetTitle("Add to Cart", UIControlState.Normal);
            }
        }