Example #1
0
        public void SaveChanges()

        {
            try {
                Viewmodel.Validators.AddressValidator validator = new Validators.AddressValidator();
                if (!validator.IsValidEmail(EditedClient.Address))
                {
                    MessageBox.Show("Wrong email !", "Email Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    switch (_selectedOperation)
                    {
                    case CrudOperation.Create:
                        if (!IsMailUniq())
                        {
                            MessageBox.Show(" email repeated!", "Email repeated", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                        else
                        {
                            _clientsManager.AddClient(EditedClient);
                        }
                        break;

                    case CrudOperation.Edit:
                        _clientsManager.EditClient(EditedClient);
                        break;
                    }
                    IsClientEditVisible = false;
                    RefreshClients();
                }
            }
            catch
            {
                MessageBox.Show("Cos poszlo nie tak", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public void SaveChanges()
 {
     _clientsManager.AddClient(EditedClient);
     IsClientEditVisible = false;
     RefreshClients();
 }