Esempio n. 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //Check the fields
            if (string.IsNullOrEmpty(FirstNameTextbox.Text))
            {
                FirstNameTextbox.BorderBrush = System.Windows.Media.Brushes.Red;
                return;
            }
            if (string.IsNullOrEmpty(LastNameTextbox.Text))
            {
                LastNameTextbox.BorderBrush = System.Windows.Media.Brushes.Red;
                return;
            }

            //Create operator entity

            var newOperator = new @operator();

            newOperator.FirstName = FirstNameTextbox.Text;
            newOperator.LastName  = LastNameTextbox.Text;
            newOperator.IsManager = checkBox.IsChecked;

            //Add The operator to the database
            if (operatorFuncs.InsertOperator(newOperator))
            {
                MessageBox.Show("Operator Created.");
                this.Close();
            }
            else
            {
                MessageBox.Show("Error Creating Operator.");
            }
        }
Esempio n. 2
0
 public bool InsertOperator(@operator newOperator)
 {
     [email protected](newOperator);
     return(dbs.SaveChanges() > 0);
 }