Exemple #1
0
        public void petMenu()
        {
            petService = new PetAppService(new PetRepo());
            while (IsRunning)
            {
                Console.Clear();
                string[] petShopItems =
                {
                    "Show all pets in shop",
                    "Add a pet to shop",
                    "Search for a pet by Id",
                    "Search for a pet by Type",
                    "Update info on a pet",
                    "Delete a pet from shop",
                    "Exit Shop"
                };
                Console.WriteLine("Type a number between 1-7");

                for (int i = 0; i < petShopItems.Length; i++)
                {
                    Console.WriteLine((i + 1) + ": " + petShopItems[i]);
                }

                int options;

                while (!int.TryParse(Console.ReadLine(), out options) || options < 1 || options > 7)
                {
                    Console.WriteLine("You didn't write a number between 1-6, Please try again");
                }

                switch (options)
                {
                case 1:
                    var pets = petService.GetAllPets();
                    MakeAListOfAllPets(pets);
                    Console.ReadLine();
                    break;

                case 2:
                    var id            = FakeDB.GetNextAvaibleId();
                    var petName       = AskQuestion("PetName:");
                    var type          = PetTypes.Alpaca;
                    var birthdate     = System.DateTime.MaxValue;
                    var soldDate      = System.DateTime.MinValue;
                    var color         = AskQuestion("color:");
                    var previousOwner = AskQuestion("previousOwner:");
                    Console.WriteLine("Set a price that is higer than 0");
                    var petPrice = double.Parse(Console.ReadLine());
                    var pet      = petService.CreatePet(new Pet(id, petName, type, birthdate, soldDate, color, previousOwner, petPrice));
                    petService.CreatePet(pet);

                    break;

                case 3:
                    FindByID();
                    break;

                //case 4:
                //    petService.UpdatePet();
                //    break;

                //case 5:
                //    petService.DeletePet();
                //    break;
                case 6:

                    break;
                }
            }
        }