private void button_Click(object sender, RoutedEventArgs e) { BusinessUser ma = new BusinessUser(); this.Visibility = Visibility.Hidden; ma.Visibility = Visibility.Visible; }
private void Button_Click(object sender, RoutedEventArgs e) { BusinessUser bs = new BusinessUser(); MainWindow mw = new MainWindow(); HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:62135/"); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var user = username_txt.Text.Trim(); var url = "api/Login/" + user; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { try { var Users = response.Content.ReadAsAsync <ABusers>().Result; byte[] pss = Convert.FromBase64String(Users.Pass); string ne = Decrypt(pss); if (ne == passwordbox.Password.ToString()) { MessageBox.Show("Welcome To Our Service, Enjoy Your Day"); if (Users.Type_user == "Admin") { this.Visibility = Visibility.Hidden; mw.Visibility = Visibility.Visible; HttpClient client3 = new HttpClient(); client3.BaseAddress = new Uri("http://localhost:62135/"); client3.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var AName = username_txt.Text; var url3 = "api/Login/" + AName; var response3 = client3.GetAsync(url3).Result; try { if (response3.IsSuccessStatusCode) { var user2 = response3.Content.ReadAsAsync <ABusers>().Result; List <ABusers> list = new List <ABusers>(); list.Add(user2); mw.username_label.Content = user2.Username; mw.image1.Source = getarray(user2.Picture); } else { MessageBox.Show(response.StatusCode + "With Message " + response.ReasonPhrase); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } } else { this.Visibility = Visibility.Hidden; bs.Visibility = Visibility.Visible; } } else { MessageBox.Show("Wrong Password"); } } catch (Exception ex) { MessageBox.Show("User Name Or Password Are Wrong"); } } else { MessageBox.Show(response.StatusCode + "not found" + response.ReasonPhrase); } HttpClient client2 = new HttpClient(); client2.BaseAddress = new Uri("http://localhost:62135/"); client2.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var UName = username_txt.Text; var url2 = "api/Login/" + UName; var response2 = client2.GetAsync(url2).Result; try { if (response2.IsSuccessStatusCode) { var user2 = response2.Content.ReadAsAsync <ABusers>().Result; List <ABusers> list = new List <ABusers>(); list.Add(user2); bs.username.Content = user2.Username; bs.image_control.Source = getarray(user2.Picture); } else { MessageBox.Show(response.StatusCode + "With Message " + response.ReasonPhrase); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }