Exemplo n.º 1
0
        public async Task createCartObjAsync()
        {
            KullanıcıSepeti cart      = new KullanıcıSepeti();
            int             userId    = Int32.Parse(Application.Current.Properties["UserId"].ToString());
            long            productId = long.Parse(Application.Current.Properties["ProductId"].ToString());

            cart.productId     = productId;
            cart.userId        = userId;
            cart.shoppingDate  = DateTime.Now;
            cart.cartId        = Int32.Parse(Application.Current.Properties["CartId"].ToString());
            cart.productAmount = Int32.Parse(tb_miktar.Text);
            cart.productUrl    = p1.ProductUrl;
            //bu kısım değişti miktar ile carpmıltım
            cart.productPrice  = Convert.ToDouble(Application.Current.Properties["ProductPrice"]);
            cart.productWeight = Convert.ToDouble(Application.Current.Properties["ProductWeight"]);


            try
            {
                btn_back.IsEnabled      = false;
                btn_addToCart.IsEnabled = false;
                var content = JsonConvert.SerializeObject(cart);

                var result = await _client.PostAsync(url, new StringContent(content, Encoding.UTF8, "application/json"));
            }
            catch (Exception exception)
            {
                await DisplayAlert(exception.Message.ToString(), "Sorun", "Tamam");
            }
        }
Exemplo n.º 2
0
        public FaturaDetay(object ft)
        {
            InitializeComponent();

            ft_tarih.Text    += (ft as KullanıcıSepeti).shoppingDate.ToString();
            ft_aciklama.Text += (ft as KullanıcıSepeti).productName.ToString();
            ft_tutar.Text    += (ft as KullanıcıSepeti).productPrice.ToString();
            smail             = ft as KullanıcıSepeti;
        }
Exemplo n.º 3
0
 public ShoppingDetail(KullanıcıSepeti model)
 {
     InitializeComponent();
     btn_back.IsEnabled   = true;
     btn_update.IsEnabled = true;
     img_ürün.Source      = model.productUrl;
     lb_adi.Text          = model.productName;
     tb_miktar.Text       = model.productAmount.ToString();
     lb_gram.Text        += model.productWeight.ToString();
     lb_fiyat.Text       += model.productPrice.ToString();
     ks = model;
 }
Exemplo n.º 4
0
        private async void Btn_update_OnClicked(object sender, EventArgs e)
        {
            btn_back.IsEnabled   = false;
            btn_update.IsEnabled = false;
            KullanıcıSepeti updateCart = new KullanıcıSepeti();
            Product         p1         = new Product();

            try
            {
                var content = await _client.GetStringAsync(ur_product);

                var list = JsonConvert.DeserializeObject <List <Product> >(content);
                SepetListe = new ObservableCollection <Product>(list);
            }
            catch (Exception ecc)
            {
                await DisplayAlert("Hata", "İnternet bağlantını kontrol edip uygulamaya bir daha giriş yap!", "Tamam");
            }

            try
            {
                updateCart.productUrl = ks.productUrl;
                //Bunlar yanlıs birim fiyatı üzerinden işlem yapılması gerekiyor.
                updateCart.productWeight = SepetListe.Where(p => p.ProductId == ks.productId).First().ProductWeight;
                updateCart.productPrice  = SepetListe.Where(p => p.ProductId == ks.productId).First().ProductPrice;
                updateCart.productId     = ks.productId;
                updateCart.userId        = ks.userId;
                updateCart.cartId        = ks.cartId;
                //alttaki ikisi yanlıs alınıyor.
                updateCart.shoppingCartId = ks.shoppingCartId;
                updateCart.shoppingDate   = ks.shoppingDate;
                updateCart.productAmount  = Int32.Parse(tb_miktar.Text);

                var content = JsonConvert.SerializeObject(updateCart);
                var result  = await _client.PutAsync(url_update + "/" + updateCart.shoppingCartId,
                                                     new StringContent(content, Encoding.UTF8, "application/json"));

                await Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                await DisplayAlert("Hata", ex.Message, "Tamam");
            }
        }