コード例 #1
0
        private async void Submit_Click(object sender, RoutedEventArgs e)
        {
            progress_bar.IsIndeterminate = true;
            //TODO : Verify the passcode provided by the user with the third-party service.
            // Hard coded passcode for now is - 1234
            if (passcode.Text == "1234")
            {
                Dictionary <string, string> apiParameters = new Dictionary <string, string>();
                apiParameters.Add("personId", num);
                // SERVICE CALL ... Check if the person exists
                //Person returnedPerson = await App.serviceClient.InvokeApiAsync<Dictionary<string,string>, Person>("getPersonFromPersonId", apiParameters);
                JToken returnedToken = await App.serviceClient.InvokeApiAsync("getPersonFromPersonId", System.Net.Http.HttpMethod.Get, apiParameters);

                Person returnedPerson = JsonConvert.DeserializeObject <Person>(returnedToken.ToString());
                if (returnedPerson == null)
                {
                    // The person does not exist. Make a service call to insert the person
                    NavigationService.Navigate(new Uri("/RegistrationPages/ProfilePage.xaml", UriKind.Relative));
                }
                else
                {
                    App.client.phoneNo           = num;
                    App.client.Id                = num;
                    App.client.isGloballyVisible = true;
                    // Navigate to profile page
                    LocalPerson p1 = new LocalPerson
                    {
                        Id        = num,
                        phoneNo   = num,
                        name      = "aaa",
                        latitude  = 0.0,
                        longitude = 0.0
                    };
                    LocalDB.insertLocalPerson(p1);
                    NavigationService.Navigate(new Uri("/MainPages/HomePage.xaml", UriKind.Relative));
                }
            }
            else
            {
                MessageBox.Show("Wrong PassCode !");
            }
        }
コード例 #2
0
        private async void Submit_Click(object sender, RoutedEventArgs e)
        {
            progress_bar.IsIndeterminate = true;
            // TODO : store profile information locally
            Person currentUser = new Person {
                Id                = num,
                phoneNo           = num,
                name              = Name_tb.Text,
                isGloballyVisible = true
            };
            LocalPerson p1 = new LocalPerson
            {
                Id        = num,
                phoneNo   = num,
                name      = Name_tb.Text,
                latitude  = 0.0,
                longitude = 0.0
            };


            App.client = currentUser;
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("personStr", JsonConvert.SerializeObject(currentUser));
            JToken returnVal = await App.serviceClient.InvokeApiAsync("insertIfNotExistsPerson", System.Net.Http.HttpMethod.Get, dict);

            //returnVal= await App.serviceClient.InvokeApiAsync("insertIfNotExistsPerson", System.Net.Http.HttpMethod.Get, dict);
            object retObject = JsonConvert.DeserializeObject <object>(returnVal.ToString());

            if (retObject != null)
            {
                LocalDB.insertLocalPerson(p1);
                NavigationService.Navigate(new Uri("/MainPages/HomePage.xaml", UriKind.Relative));
            }
            else
            {
                // Unlikely to occur
                MessageBox.Show("Error: Person Already Exists");
            }
        }