Example #1
0
        private async void RemoveClicked(object obj)
        {
            CartPageDataService cartPageData = new CartPageDataService();
            var SelectedItem = (ItemCatalogueModel)obj;
            var UserId       = AppSettings.GetValueOrDefault(Resources.UserId, Resources.DefaultIntValue);
            var formcontent  = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>(Resources.UserId, UserId),
                new KeyValuePair <string, string>(Resources.ItemId, SelectedItem.ItemId.ToString()),
            });
            HttpResponseMessage response = await cartPageData.ServiceRemove(obj);

            var status = response.StatusCode;

            if (status == HttpStatusCode.OK)
            {
                CartItems.Remove(SelectedItem);
                CartItemsCount = CartItems.Count;
                AppSettings.AddOrUpdateValue(Resources.CartItemCount, CartItemsCount.ToString());

                if (CartItemsCount == 0)
                {
                    await Navigation.PushAsync(new EmptyCartPage());
                }
            }
            else
            {
                DependencyService.Get <IMessage>().LongAlert(Resources.ErrorMsg);
            }
        }
Example #2
0
        public async void GetCartItems()
        {
            CartPageDataService cartPageData = new CartPageDataService();
            var ItemCatalogue = await cartPageData.GetServiceCartItems();

            CartItems      = new ObservableCollection <ItemCatalogueModel>(ItemCatalogue);
            CartItemsCount = CartItems.Count;
            AppSettings.AddOrUpdateValue(Resources.CartItemCount, CartItemsCount.ToString());
            if (CartItemsCount == 0)
            {
                await Navigation.PushAsync(new EmptyCartPage());
            }
        }