Example #1
0
        private async void PerformUserLogin(object sender, System.Windows.Input.GestureEventArgs e)
        {
            username = userName.Text;
            phoneNo = userPhone.Text;

            if (MainPage.online == true)
            {
                Users user = new Users();
                user.Name = username;
                user.Phone_no = phoneNo;
                user.uri = "uri here";
                MobileService = new MobileServiceClient(
                     "https://shopappdata.azure-mobile.net/",
                       "dkwwuiuHYYQwbozjKaWRJYYpEiTjFt73"
                );
                userTable = MobileService.GetTable<Users>();

                await userTable.InsertAsync(user);
                user_id = user.Id;

                MainPage.settings.Add("id", user_id);
                MainPage.settings.Add("Pnumber", phoneNo);
                MainPage.settings.Add("name", username);
            }
            else
            {
                // Prompt
            }

            // TODO: send this username and phoneno. to be added into the database


            NavigationService.GoBack();
        }
        public async void AcquirePushChannel()
        {
            CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");

            if (CurrentChannel == null)
            {
                CurrentChannel = new HttpNotificationChannel("MyPushChannel");
                CurrentChannel.Open();
                CurrentChannel.BindToShellTile();
            }

            var uri = CurrentChannel.ChannelUri.ToString();

            userTable = MobileService.GetTable<Users>();

            if (settings.Contains("Pnumber"))
            {
                Users up = new Users();

                up.uri = uri;
                up.Id = user_id;
                up.Name = user_name;
                up.Phone_no = pnumber;

                await userTable.UpdateAsync(up);
            }
        }