Esempio n. 1
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            string msg = null;
            var f = new FermentableAdjunct();
            f.Name = NameTextBox.Text;
            f.Origin = OriginTextBox.Text;
            f.MashNeeded = (MashNeededCheckBox.IsChecked == true);
            f.AdjuctType = TypeComboBox.Text;


            float floatVal = 0;
            if (float.TryParse(PotentialTextBox.Text, out floatVal))
                f.Potential = floatVal;
            else
                msg = "Please provide a valid float value for Potential";

            int intVal = 0;
            if (int.TryParse(ColorTextBox.Text, out intVal))
                f.Color = intVal;
            else
                msg = "Please provide a valid integer value for Color";

            if (int.TryParse(MaxPartTextBox.Text, out intVal))
                f.MaxPart = intVal;
            else
                msg = "Please provide a valid integer value for Max. part";

            if (msg != null)
            {
                MessageBox.Show(msg);
                return;
            }

            Repo.AddFermentable(f);

            Fermentables.Clear();
            var fList = Repo.Get();
            foreach (FermentableAdjunct x in fList)
                Fermentables.Add(x);

            listView.ItemsSource = Fermentables;

            // Reset GUI
            AddButton.Content = "Add";
            NameTextBox.Text = String.Empty;
            OriginTextBox.Text = String.Empty;
            MashNeededCheckBox.IsChecked = false;
            PotentialTextBox.Text = String.Empty;
            ColorTextBox.Text = String.Empty;
            MaxPartTextBox.Text = String.Empty;
            TypeComboBox.Text = String.Empty;


        }
Esempio n. 2
0
        public void AddFermentable(FermentableAdjunct aFermentable)
        {

            var found = ferms.Any(x => x.Name == aFermentable.Name);
            if (found)
            {
                var ferm = ferms.FirstOrDefault(x => x.Name == aFermentable.Name);
                ferms.Remove(ferm);

                ferms.Add(aFermentable);
            }
            else
                ferms.Add(aFermentable);

            Persist();

        }
Esempio n. 3
0
 public void RemoveFermentable(FermentableAdjunct aFermentable)
 {
     ferms.Remove(aFermentable);
     Persist();
 }