async void DeleteProduct(Product Item)
        {
            try
            {
                Config.ShowDialog();
                Dictionary <string, int> CartItem = new Dictionary <string, int>();
                CartItem.Add("cart_id", Item.id);
                CartItem.Add("product_id", Item.id);
                CartItem.Add("user_id", int.Parse(Application.Current.Properties["user_id"].ToString()));

                var response = await CartLogic.DeleteCartItem(CartItem);

                if (response.status == 200)
                {
                    getData();
                }
                else if (response.status == 220)
                {
                    getData();
                }
                else
                {
                    getData();
                }
                Config.HideDialog();
            }
            catch (Exception ex)
            {
                Config.ErrorStore("CartPage-DeleteProduct", ex.Message);
                Config.HideDialog();
                Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
            }
        }
        public void DeleteCartItem()
        {
            var obj = cartLogic.GetCartItems(usr.UserId);

            if (obj.Count > 0)
            {
                var data   = obj.FirstOrDefault();
                var status = cartLogic.DeleteCartItem(data.Id);
                Assert.IsTrue(status);
            }
        }
Beispiel #3
0
        public HttpResponseMessage DeleteCartItem(int id)
        {
            var status = logic.DeleteCartItem(id);

            if (status)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, logic.ErrorMessage));
            }
        }
Beispiel #4
0
        async void DeleteProduct(Cart Item)
        {
            try
            {
                Config.ShowDialog();
                Dictionary <string, int> CartItem = new Dictionary <string, int>();
                CartItem.Add("cart_id", Item.id);
                CartItem.Add("product_id", Item.product_id);
                CartItem.Add("user_id", int.Parse(Application.Current.Properties["user_id"].ToString()));

                var response = await CartLogic.DeleteCartItem(CartItem);

                if (response.status == 200)
                {
                    grandTotalVisible.IsVisible = true;
                    HomeVM.MyCartCounter        = response.cart_count;
                    MessagingCenter.Send((App)Application.Current, "NavigationBar", _pageTitle);
                    Config.HideDialog();
                    var removeItem = ViewModel.CartItems.Where(p => p.product_id == Item.product_id && p.id == Item.id).Single();
                    ViewModel.CartItems.Remove(removeItem);

                    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())
                    {
                        grandTotalVisible.IsVisible = true;
                        b_cart.IsVisible            = true;
                        //header.IsVisible = true;
                    }

                    if (ViewModel.CartItems.Count == 0)
                    {
                        EmptyCart();
                    }
                }
                else if (response.status == 220)
                {
                    HomeVM.MyCartCounter = response.cart_count;
                    MessagingCenter.Send((App)Application.Current, "NavigationBar", _pageTitle);
                    EmptyCart();
                }
                else
                {
                    HomeVM.MyCartCounter = response.cart_count;
                    EmptyCart();
                }
                Config.HideDialog();
                //Config.SnackbarMessage(response.message);
            }
            catch (Exception ex)
            {
                Config.ErrorStore("CartPage-DeleteProduct", ex.Message);
                Config.HideDialog();
                Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
            }
        }