Exemplo n.º 1
0
        private void BtnOrder_Click(object sender, RoutedEventArgs e)
        {
            if (TbQuantity.Text != "")
            {
                CartItem item = new CartItem(Detail.id, Detail.name, Detail.image, Detail.price, Convert.ToInt32(TbQuantity.Text));
                Carts    cart = new Carts();
                cart.AddToCart(item);
                MainPage.contentFrame.Navigate(typeof(ShowCart));
            }

            #region
            //if (TbQuantity.Text != "")
            //{
            //    //check xem đã tồn tại sản phẩm trong giỏ hàng chưa
            //    int soluong = 0;
            //    List<Cart> listSelected = AddCartService.getDataCart();
            //    foreach(var item in listSelected)
            //    {
            //        if(item.id == Detail.id)
            //        {
            //            soluong = item.Quantity +Convert.ToInt32(TbQuantity.Text);
            //            break;
            //        }
            //    }
            //    if (soluong !=0)
            //    {
            //        AddCartService.updateQuantity(Detail.id, soluong);
            //        MainPage.contentFrame.Navigate(typeof(ShowCart));
            //        return;
            //    }

            //    Cart c = new Cart(Detail.id, Detail.name, Detail.image, Detail.description, Detail.price, Convert.ToInt32(TbQuantity.Text));
            //    AddCartService.AddtoCart(c);
            //    TbQuantity.Text = "";
            //    MainPage.contentFrame.Navigate(typeof(ShowCart));
            //}

            #endregion
        }