Beispiel #1
0
 private void AddNewAnimalToDatabase()
 {
     try
     {
         Animal animal = new Animal();
         Trait  traits = new Trait();
         Health health = new Health();
         UserInterface.DisplayIntroToAddingAnAnimal();
         UserInterface.PressAnyKeyToContinue();
         animal.type                   = UserInterface.AskTypeOfAnimal();
         animal.gender                 = UserInterface.AskGenderOfAnimal();
         animal.name                   = UserInterface.AskNameOfAnimal();
         animal.breed                  = UserInterface.AskBreedOfAnimal();
         animal.price                  = UserInterface.AskPriceOfAnimal();
         animal.entryDate              = DateTime.Now;
         animal.adopted                = false;
         animal.age                    = UserInterface.AskAgeOfAnimal();
         traits.size                   = UserInterface.AskSizeOfAnimal();
         traits.color                  = UserInterface.AskColorOfAnimal();
         traits.activityLevel          = UserInterface.AskActivityLevelOfAnimal();
         health.foodConsumptionPerWeek = UserInterface.AskAboutFoodConsumptionOfAnimal();
         health.receivedShots          = true;
         UserInterface.AskIfShotsAreUpToDateOnAnimal();
         string choice = UserInterface.ConfirmTheAdditionOfTheAnimal();
         if (choice == "yes")
         {
             db.Animals.InsertOnSubmit(animal);
             db.SubmitChanges();
             Room firstRoom = FindFirstRoomAvailableToAddNewAnimalTo();
             AssignRoomVariables(firstRoom, animal.animalId, traits.size);
             traits.animalId = animal.animalId;
             health.animalId = animal.animalId;
             db.Traits.InsertOnSubmit(traits);
             db.Healths.InsertOnSubmit(health);
             db.SubmitChanges();
             UserInterface.PressAnyKeyToContinue();
             DecideWhatToDoAsAnEmployee();
         }
         else if (choice == "no")
         {
             DecideWhatToDoAsAnEmployee();
         }
         else
         {
             UserInterface.DisplayWrongKeyTyped();
             AddNewAnimalToDatabase();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         UserInterface.DisplayWrongKeyTyped();
         AddNewAnimalToDatabase();
     }
 }