/// <summary> /// Function for login fase used by Enterkey event and Login butten event /// </summary> private void login() { if (string.IsNullOrEmpty(tb_mail.Text) || string.IsNullOrEmpty(pb_password.Password) || string.IsNullOrEmpty(tb_mail.Text) && string.IsNullOrEmpty(pb_password.Password)) { MessageBox.Show("Please fill out username and password"); } else { if (tb_password.Visibility == Visibility.Visible) { pb_password.Password = tb_password.Text; } string JSONapikey = HttpApiRequest.ClimateLogin(tb_mail.Text, pb_password.Password); if (string.IsNullOrEmpty(JSONapikey)) { MessageBox.Show("Wrong username or password"); } else { UserInformation.ApiKey = JsonDataConverter.deserializedApikey(JSONapikey); UserInformation.Mail = tb_mail.Text; UserInformation.Password = pb_password.Password; Climate c = new Climate(); c.Show(); Close(); } } }