private void BehindButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            HomeManager home = new HomeManager();

            home.Show();
            Close();
        }
Example #2
0
 private void LoginButtonClicked(object sender, RoutedEventArgs routedEvent)
 {
     AccountActivate.IsRegister = false;
     CreateLoginFromInputData();
     if (ValidateDataLogin())
     {
         string passwordEncryption = Utils.Security.Encrypt(login.password);
         login.password = passwordEncryption;
         string     urlBase = "http://127.0.0.1:5000/";
         RestClient client  = new RestClient(urlBase);
         client.Timeout = -1;
         var request = new RestRequest("logins", Method.POST);
         var json    = JsonConvert.SerializeObject(login);
         request.AddParameter("application/json", json, ParameterType.RequestBody);
         System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); };
         try
         {
             IRestResponse response = client.Execute(request);
             if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK)
             {
                 Models.Token token = JsonConvert.DeserializeObject <Models.Token>(response.Content);
                 cookies      = response.Cookies;
                 tokenAccount = token;
                 loginAccount = login;
                 if (token.memberATEType == Number.NumberValue(NumberValues.TWO))
                 {
                     ChooseAccount chooseAccount = new ChooseAccount();
                     chooseAccount.InitializeHome();
                     chooseAccount.Show();
                     Close();
                 }
                 else
                 {
                     if (token.memberATEType == Number.NumberValue(NumberValues.THREE))
                     {
                         HomeManager home = new HomeManager();
                         home.Show();
                         Close();
                     }
                     else
                     {
                         HomeClient home = new HomeClient();
                         home.InitializeMenu();
                         home.Show();
                         Close();
                     }
                 }
             }
             else
             {
                 Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content);
                 MessageBox.Show(responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         catch (Exception exception)
         {
             TelegramBot.SendToTelegram(exception);
             LogException.Log(this, exception);
             MessageBox.Show(exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     else
     {
         MessageBox.Show("Por favor, Ingrese datos correctos en los campos marcados en rojo", "Datos Incorrectos", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }