Esempio n. 1
0
 private async void Deleteitem_OnClicked(object sender, EventArgs e)
 {
     if (_selectedAddressId != null)
     {
         var addresses = new TBL_Addresses()
         {
             id = _selectedAddressId,
         };
         await TBL_Addresses.Remove(addresses);
         await getUserAddresses();
     }
 }
        private async void Btnsetdelivery_OnClicked(object sender, EventArgs e)
        {
            try
            {
                if (btnaddnewaddress.Text != "Modify Address")
                {
                    ///add address
                    string c_add;
                    int    selectedIndex = picker.SelectedIndex;
                    c_add = "" + txtstreet.Text + ", " + txtfloor.Text + " " + (string)picker.ItemsSource[selectedIndex];
                    if (_label != null)
                    {
                        progressplaceorder.IsVisible = true;
                        var addrress = new TBL_Addresses
                        {
                            user_id  = user_id,
                            street   = txtstreet.Text,
                            floor    = txtfloor.Text,
                            Address  = c_add,
                            add_lat  = order_lat,
                            add_long = order_long,
                            Label    = _label,
                            Notes    = txtnotes.Text
                        };
                        await TBL_Addresses.Insert(addrress);
                        await DisplayAlert("Info", "New address added. You can now choose this address where you want the items to be delivered.", "OK");

                        await Navigation.PopAsync(true);
                    }
                    else
                    {
                        await DisplayAlert("Alert", "Please select a label for this address.", "OK");
                    }
                }
                else
                {
                    //modify address
                    string c_add;
                    var    selectedIndex = picker.SelectedIndex;
                    c_add = "" + txtstreet.Text + ", " + txtfloor.Text + " " + (string)picker.ItemsSource[selectedIndex];
                    if (_label != null)
                    {
                        progressplaceorder.IsVisible = true;
                        var addrress = new TBL_Addresses
                        {
                            id       = _selectedAddressId,
                            user_id  = user_id,
                            street   = txtstreet.Text,
                            floor    = txtfloor.Text,
                            Address  = c_add,
                            add_lat  = order_lat,
                            add_long = order_long,
                            Label    = _label,
                            Notes    = txtnotes.Text
                        };
                        await TBL_Addresses.Update(addrress);
                        await DisplayAlert("Info", "Address updated successfully.", "OK");

                        await Navigation.PopAsync(true);
                    }
                    else
                    {
                        await DisplayAlert("Alert", "Please select a label for this address.", "OK");
                    }
                }
            }
            catch
            {
                await Navigation.PushAsync(new NoInternetPage(), true);
            }
        }