private void AddNewPhysicalPersonClientButton_OnClick(object sender, RoutedEventArgs e) { var addingClientWindow = new AddingPhysicalPersonClientWindow(); if (addingClientWindow.ShowDialog() == true) { using (var repo = new PhysicalPersonClientRepository()) { if (!DateTime.TryParse(addingClientWindow.BirthdayTextBox.Text, out var birthday)) { MessageBox.Show("Ошибка ввода дня рождения"); return; } ClientType clientType = Convert.ToBoolean(addingClientWindow.IsVipCheckBox.IsChecked) ? ClientType.Vip : ClientType.Usual; var client = new PhysicalPersonClient(addingClientWindow.FirstNameTextBox.Text, addingClientWindow.LastNameTextBox.Text, addingClientWindow.LastNameTextBox.Text, birthday, clientType); PhysicalPersonClients.Add(client); repo.AddClient(client); repo.Save(); } } }
private void RemovePhysicalPersonClientButton_OnClick(object sender, RoutedEventArgs e) { using (var repo = new PhysicalPersonClientRepository()) { repo.RemoveClient(SelectedPhysicalPersonClient); repo.Save(); repo.Update(SelectedPhysicalPersonClient); } PhysicalPersonClients.Remove(SelectedPhysicalPersonClient); }