示例#1
0
        public void AddAnimal()
        {
            database.Animals.Clear();
            animalLogic.AddAnimal(testAnimal);

            Assert.IsNotNull(database.GetAllAnimals().Find(x => x == testAnimal));
        }
示例#2
0
        /// <summary>
        /// Button click event that when triggered adds the animal to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (TxtAnimalName.Text != "" && NudAnimalWeight.Value != 0 && RtbCharacteristics.Text != "" && PbAnimalImage.Image != null)
            {
                byte[] imageBytes  = File.ReadAllBytes(OfdImage.FileName);
                string imageBase64 = Convert.ToBase64String(imageBytes);

                Animal A = new Animal()
                {
                    name = TxtAnimalName.Text, age = (int)NudAnimalAge.Value, weight = (int)NudAnimalWeight.Value, gender = (Animal.Genders)Convert.ToInt32(!RadAnimalMale.Checked), species = (Animal.Species)Enum.Parse(typeof(Animal.Species), CbAnimalType.Text), cage = (int)NudAnimalCage.Value, price = (float)NudAnimalPrice.Value, characteristics = RtbCharacteristics.Lines.ToList(), image = imageBase64, breed = TxtBreed.Text, about = RtbAbout.Text
                };
                animalLogic.AddAnimal(A);
                PbAnimalImage.Image = null;
                UpdateAnimalList();
                TodoToday();

                MessageBox.Show("Dier succesvol toegevoegd.", "Notice", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("Informatie is onvolledig ingevoerd.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
 public void AddAnimal(AnimalEntity animal)
 {
     _animalLogic.AddAnimal(animal);
 }