示例#1
0
        public void RemoveAnimal()
        {
            database.Animals.Clear();
            animalLogic.AddAnimal(testAnimal);
            if (!database.GetAllAnimals().Contains(testAnimal))
            {
                Assert.Fail();
            }
            animalLogic.RemoveAnimal(testAnimal);

            Assert.IsFalse(database.GetAllAnimals().Contains(testAnimal));
        }
示例#2
0
        /// <summary>
        /// Button click event that when triggered that removes the specified animal from the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAnimalDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show($"Weet je zeker dat je {LvAnimalList.SelectedItems[0].Text} wilt verwijderen?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                foreach (ListViewItem item in LvAnimalList.SelectedItems)
                {
                    Animal A = new Animal()
                    {
                        name     = item.Text,
                        age      = int.Parse(item.SubItems[1].Text),
                        weight   = int.Parse(item.SubItems[2].Text),
                        gender   = (Animal.Genders)Enum.Parse(typeof(Animal.Genders), item.SubItems[3].Text),
                        price    = float.Parse(item.SubItems[4].Text),
                        species  = (Animal.Species)Enum.Parse(typeof(Animal.Species), item.SubItems[5].Text),
                        cage     = int.Parse(item.SubItems[6].Text),
                        reserved = (item.SubItems[7].Text == "Ja" ? true : false),
                    };

                    animalLogic.RemoveAnimal(A);
                    UpdateAnimalList();
                    TodoToday();
                }
            }
        }