コード例 #1
0
ファイル: RestService.cs プロジェクト: ararog/Ow-WP
        public async Task<User> Verify(Registration registration)
        {
            HttpStringContent postContent = new HttpStringContent(JsonConvert.SerializeObject(registration));
            postContent.Headers["Content-Type"] = "application/json";

            try 
            { 
                HttpResponseMessage response = await client.PostAsync(new Uri(serviceUrl, "/api/v1/users/verify"), postContent);

                if (response.IsSuccessStatusCode) 
                {
                    string content = await response.Content.ReadAsStringAsync();
                    User user = JsonConvert.DeserializeObject<User>(content);

                    return user;
                }
            }
            catch
            {

            }

            return null;
        }
コード例 #2
0
ファイル: LoginPage.xaml.cs プロジェクト: ararog/Ow-WP
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            WaitIndicator.IsVisible = true;

            Login login = new Login();
            login.CountryCode = CountryCodeField.Text;
            login.PhoneNumber = PhoneNumberField.Text;

            User user = await restService.Signin(login);

            WaitIndicator.IsVisible = false;

            if (user != null)
            {
                Messenger.Default.Send(user, Constants.ChatManagerStartChatSession);

                model.Session.User = user;
                model.Session.SaveData();

                NavigationService.Navigate(new Uri("/View/MainPage.xaml", UriKind.RelativeOrAbsolute));
            }
            else
            {
                Registration registration = new Registration();
                registration.CountryCode = CountryCodeField.Text;
                registration.PhoneNumber = PhoneNumberField.Text;

                PhoneApplicationService.Current.State[Constants.Registration] = registration;

                NavigationService.Navigate(new Uri("/View/RegistrationPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }