예제 #1
0
        private static void Main()
        {
            var city = SelectCity();

            var storage   = new NativeStorageProvider();
            var authToken = storage.AuthToken;

            if (string.IsNullOrEmpty(authToken))
            {
                var credentialsProvider = new ConsoleCredentialsProvider();
                var loginRequest        = new LoginRequest(credentialsProvider.Login, credentialsProvider.Password);
                var response            = ImaxApi.Login(loginRequest).Result;
                if (response.Succeeded)
                {
                    authToken = storage.AuthToken = response.Token;
                }
                else
                {
                    return;
                }
            }

            var profileRequest  = new ProfileRequest(authToken);
            var profileResponse = ImaxApi.Profile(profileRequest).Result;

            var registerRequest  = new RegisterRequest(new CustomerName("Vasya", null, "Pupkin"), Gender.Male, new DateTime(2012, 12, 21), PhoneNumber.Parse("+380123456789"), "*****@*****.**", "qwerty");
            var registerResponse = ImaxApi.Register(registerRequest).Result;
        }
예제 #2
0
        private async void Login()
        {
            LoginButton.IsEnabled = false;

            var registerRequest = new LoginRequest(LoginBox.Text, PasswordBox.Password);
            var response        = await ImaxApi.Login(registerRequest);

            if (response.Succeeded)
            {
                ApplicationData.Current.LocalSettings.Values.Add("AuthToken", response.Token);
                Frame.Navigate(typeof(ProfilePage));
            }
            else
            {
                await new MessageDialog("Sorry, an error occured.").ShowAsync();
                LoginButton.IsEnabled = true;
            }
        }