Пример #1
0
        // PUT: api/Cart/2 update
        public void Put(int id, [FromBody] Cart updateCart)
        {
            var cl = new CartLogic();

            updateCart.Id = id;
            cl.UpdateCart(updateCart);
        }
Пример #2
0
 public ActionResult ShoppingCart(List <Cart_Item> items)
 {
     foreach (var i in items)
     {
         cart_Service.UpdateCart(i.cart_item_id, i.quantity);
     }
     return(RedirectToAction("ShoppingCart"));
 }
Пример #3
0
        private async void decreseQuantity_Tapped(object sender, EventArgs e)
        {
            try
            {
                var image = (Frame)sender;
                if (image.GestureRecognizers.Count > 0)
                {
                    var tapGesture   = (TapGestureRecognizer)image.GestureRecognizers[0];
                    var Item         = (Product)tapGesture.CommandParameter;
                    int quantityItem = Item.cart_quantity;
                    if (quantityItem > 1)
                    {
                        Config.ShowDialog();
                        quantityItem -= 1;
                        Dictionary <string, string> CartItem = new Dictionary <string, string>();
                        CartItem.Add("product_id", Item.id.ToString());
                        CartItem.Add("quantity", quantityItem.ToString());
                        CartItem.Add("update_type", "quantity");
                        CartItem.Add("user_id", Application.Current.Properties["user_id"].ToString());

                        var response = await CartLogic.UpdateCart(CartItem);

                        if (response.status == 200)
                        {
                            getData();
                        }
                        else
                        {
                            Config.ErrorSnackbarMessage(response.message);
                        }
                        Config.HideDialog();
                    }
                    else
                    {
                        DeleteProduct(Item);
                    }
                }
            }
            catch (Exception ex)
            {
                Config.ErrorStore("CartPage-decreseQuantity_Clicked", ex.Message);
                Config.HideDialog();
            }
        }
Пример #4
0
        private async void increseQuantity_Tapped(object sender, EventArgs e)
        {
            try
            {
                var image = (Frame)sender;
                if (image.GestureRecognizers.Count > 0)
                {
                    var tapGesture = (TapGestureRecognizer)image.GestureRecognizers[0];
                    var Item       = (Cart)tapGesture.CommandParameter;

                    int quantityItem = Item.quantity;
                    if (quantityItem >= 1 && quantityItem < Item.product_quantity)
                    {
                        Config.ShowDialog();
                        quantityItem += 1;
                        Dictionary <string, string> CartItem = new Dictionary <string, string>();
                        CartItem.Add("cart_id", Item.id.ToString());
                        CartItem.Add("product_id", Item.product_id.ToString());
                        CartItem.Add("quantity", quantityItem.ToString());
                        CartItem.Add("update_type", "quantity");
                        CartItem.Add("user_id", Application.Current.Properties["user_id"].ToString());

                        var response = await CartLogic.UpdateCart(CartItem);

                        if (response.status == 200)
                        {
                            HomeVM.MyCartCounter = response.cart_count;
                            MessagingCenter.Send((App)Application.Current, "NavigationBar", _pageTitle);
                            ViewModel.CartItems = new ObservableCollection <Cart>(response.data);
                            decimal total        = 0;
                            int     itemQuantity = 0;
                            foreach (var item in response.data)
                            {
                                total        += decimal.Parse(item.total_without_tax);
                                itemQuantity += 1;
                            }
                            //t_total.Text = "Rs " + total;
                            t_quantity.Text = itemQuantity + " Items";
                            m_total.Text    = "Rs " + total;
                            b_total.Text    = "Rs " + total;
                            TotalLimit      = total;
                            //b_quantity.Text = itemQuantity + " Items";
                            if (response.data.Any())
                            {
                                b_cart.IsVisible = true;
                                //header.IsVisible = true;
                            }
                        }
                        else
                        {
                            Config.SnackbarMessage(response.message);
                        }
                        Config.HideDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                Config.ErrorStore("CartPage-increseQuantity_Clicked", ex.Message);
                Config.HideDialog();
            }
        }