public bool AddAnimalKind(string name, EatingStrategy eatingStrategy, Biome biome)
        {
            AnimalKind kind = new AnimalKind(name, biome, eatingStrategy);

            _animalKinds.Create(kind);

            try{
                _animalKinds.Save();
                NotifyPropertyChanged();
                return(true);
            } catch (DbUpdateException ex) {
                _animalKinds.Remove(kind);
                return(false);
            }
        }
Beispiel #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (this.Validate())
            {
                string         name           = nameTextBox.Text;
                EatingStrategy eatingStrategy = (EatingStrategy)eatingStrategyCombo.SelectedItem;
                Biome          biome          = (Biome)biomeCombo.SelectedValue;

                if (vm.Create(new AnimalKind(name, biome, eatingStrategy)))
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Вид животных с таким названием уже существует!");
                }
            }
        }
Beispiel #3
0
 public AnimalKind(string name, Biome biome, EatingStrategy eatingStrategy)
 {
     Name           = name;
     Biome          = biome;
     EatingStrategy = eatingStrategy;
 }