Example #1
0
 public void Post([FromBody] Pets pet)
 {
     _petsService.SavePet(pet);
 }
Example #2
0
        public void MakeMenu()
        {
            Console.WriteLine("\n____1: Display all available pets \n____2: Delete a pet \n____3: Create a new pet \n____4: Search by type \n____5: Update a pet \n____6: Sort pets by price from lowest \n____7: Get 5 cheapest available pets");

            var selection = Convert.ToInt32(Console.ReadLine());

            switch (selection)
            {
            case 1:

                PrintList(_PetsService.ReadAllPets());
                MakeMenu();
                break;

            case 2:
                int idForDelete = PrintFindPetById();
                _PetsService.DeletePet(idForDelete);
                break;

            case 3:
                var name          = Question("name: ");
                var color         = Question("color: ");
                var type          = Question("type: ");
                var birthdate     = Question3("Birth Date (Format 7777/07/77): ");
                var price         = Question1("price: ");
                var solddate      = Question3("Sold Date (Format 7777/07/77): ");
                var previousowner = Question("Previous Owner: ");
                var pet           = _PetsService.CreatePet(name, color, type, birthdate, price, solddate, previousowner);
                _PetsService.SavePet(pet);
                MakeMenu();
                break;

            case 4:

                Console.WriteLine("Enter type to look for: ");
                var search     = Console.ReadLine();
                var petsByType = _PetsService.SearchPetsByType(search);

                Console.ReadLine();
                Console.Clear();
                break;


            case 5:
                var idEdit  = PrintFindPetById();
                var petEdit = _PetsService.SearchById(idEdit);

                var newName          = Question("Name of Pet:");
                var newColor         = Question("Color:");
                var newType          = Question("Type:");
                var newBirthDate     = Question3("Birth Date:");
                var newPrice         = Question1("Price:");
                var newSoldDate      = Question3("Sold Date:");
                var newPreviousOwner = Question("Previous Owner:");
                _PetsService.UpdatePet(new Pets()
                {
                    ID            = idEdit,
                    Name          = newName,
                    Color         = newColor,
                    Type          = newType,
                    BirthDate     = newBirthDate,
                    Price         = newPrice,
                    SoldDate      = newSoldDate,
                    PreviousOwner = newPreviousOwner
                });


                Console.WriteLine("Edit Done");
                Console.ReadLine();

                break;
                UpdatePet();
                MakeMenu();
                break;
            }
        }