private async void insertCart(Library.Models.Cart newCart)
        {
            Response <object> result = await APIHelper.Instance.Post <Response <object> >
                                           (ApiRoutes.Cart.InsertCart, newCart);

            if (result.IsSuccess)
            {
                CustomerWindow.Instance.notifier.ShowSuccess("Cart Added");
            }
            else
            {
                CustomerWindow.Instance.notifier.ShowError("System Error");
            }
        }
        private async void addToCart_Click(object sender, RoutedEventArgs e)
        {
            CustomerWindow.Instance.startWaitting();

            Library.Models.Cart newCart = new Library.Models.Cart();
            newCart.UserId    = AuthenticatedUser.user.UserId;
            newCart.ProductId = this.productId;
            newCart.Quantity  = (int)quantity.Value;

            Response <int> result = await APIHelper.Instance.Get <Response <int> >
                                        (ApiRoutes.Utility.makeCheckCartURL(newCart));

            if (result.Result == 1)
            {
                insertCart(newCart);
            }
            else
            {
                CustomerWindow.Instance.notifier.ShowError("Quantity Too Large");
            }
            CustomerWindow.Instance.endWatting();
        }
示例#3
0
        public async void initData(Library.Models.Cart value)
        {
            cart = value;

            Response <ProductDisplay> display = await APIHelper.Instance.Get <Response <ProductDisplay> >
                                                    (ApiRoutes.Product.getProductDisplay.Replace("{id}", value.ProductId));

            await loadUrlImg(display.Result.ImgURL);

            productName.Text     = display.Result.ProductName;
            productPrice.Text    = string.Format("{0:N0}", display.Result.Price);
            productQuantity.Text = string.Format("Quantity: {0}", value.Quantity.ToString());

            unitPrice = display.Result.Price;

            CartMain.Instance.totalMoney += value.Quantity * display.Result.Price;
            if (CartMain.Instance.totalMoneyText != null)
            {
                CartMain.Instance.totalMoneyText.Text = string.Format
                                                            ("Total: {0:N0} VNĐ", CartMain.Instance.totalMoney);
            }
        }