public static AuthenticationModel Login(AccountLoginModel loginModel)
 {
     var client = new RestClient(BaseUrl);
         var request = InitRequest("/login", Method.POST, loginModel);
         IRestResponse<AuthenticationModel> response = client.Execute<AuthenticationModel>(request);
         ConfigurationManager.AppSettings["accessToken"] = response.Data.Token;
         return response.Data;
 }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var model = new AccountLoginModel();
            model.Email = Email.Text;
            model.Password = Password.Password;

            var client = new RestClient("http://minitrelloapis.apphb.com");
            var request = new RestRequest("/login", Method.POST);
            request.RequestFormat = DataFormat.Json;
            request.AddBody(model);

            var asyncHandler = client.ExecuteAsync<AuthenticationModel>(request, r =>
            {
                if (r.ResponseStatus == ResponseStatus.Completed)
                {
                    if (r.Data != null)
                    {
                        App.Token = r.Data.Token;
                        NavigationService.Navigate(new Uri("/organization.xaml", UriKind.Relative));
                    }
                }
            });
        }