private void SignUpButtonClick(object sender, RoutedEventArgs e) { if (!authService.isExist(loginSignIn.Text)) { (Application.Current as App).currentUser = authService.SignUp(loginSignIn.Text, passwordSignIn.Password); if ((Application.Current as App).currentUser == null) { MessageBox.Show("Введен неверный формат почты или слишком короткий пароль. Аккаунт не зарегестрирован"); } else { mainWindow.profileButton.Visibility = Visibility.Visible; mainWindow.cartButton.Visibility = Visibility.Visible; mainWindow.signInButton.Visibility = Visibility.Collapsed; Customer customer = new Customer { User = (Application.Current as App).currentUser }; profileService.Add(customer); this.Close(); } } else { MessageBox.Show("Пользователь уже существует"); } }
public void AddProfile() { ProfileService profileService = new ProfileService(); ProfileService.reload(); Profile profile = profileService.Get(1); profile.Name = "Big Ol test"; int newId = 100; profile.ProfileID = newId; profileService.Add(profile); List <Profile> profiles = profileService.ListAll(); Assert.IsNotNull(profiles); Assert.AreEqual(4, profiles.Count); profile = null; profile = profileService.Get(newId); profileService.Remove(profile); //Assert.IsNull(profileService.Get(newId)); profiles = profileService.ListAll(); Assert.IsNotNull(profiles); Assert.AreEqual(3, profiles.Count); }
private void btnAddOrEdit_Click(object sender, EventArgs e) { var profileService = new ProfileService(); if (profile == null) { profileService.Add(txtName.Text, txtDescription.Text); } else { profile.Name = txtName.Text; profile.Description = txtDescription.Text; profileService.Update(profile); } this.Close(); }
private void SignUpButtonClicked(object sender, RoutedEventArgs e) { if (customerRB.IsChecked == true) { Customer customer = new Customer { UserId = (Application.Current as App).currentUser.Id, FirstName = userFirstName.Text, LastName = userLastName.Text, Address = userAddress.Text }; using (var context = new FarmersMarketContext((Application.Current as App).ConnectionString)) { ProfileService profileService = new ProfileService(context); profileService.Add(customer); } } else if (sellerRB.IsChecked == true) { Seller seller = new Seller { UserId = (Application.Current as App).currentUser.Id, FirstName = userFirstName.Text, LastName = userLastName.Text, Address = userAddress.Text }; using (var context = new FarmersMarketContext((Application.Current as App).ConnectionString)) { ProfileService profileService = new ProfileService(context); profileService.Add(seller); } } else { MessageBox.Show("Выберите вашу роль"); return; } MessageBox.Show("Аккаунт успешно зарегестрирован."); this.Close(); mainWindow.profileButton.Visibility = Visibility.Visible; mainWindow.cartButton.Visibility = Visibility.Visible; mainWindow.signInButton.Visibility = Visibility.Collapsed; }