public static int DeleteType(int TypeId) { return(TypeService.DeleteType(TypeId)); }
// starts the UI public void StartUI() { string[] menuItems = { "List all pets", "Add pet", "Delete pet", "Edit pet", "Search by type", "Sort pets by price", "Get 5 cheapest pets", "Create Customer", "Delete Customer", "Edit Customer", "List all Customer", "Create Type", "Delete Type", "Edit Type", "List all Types", "Exit" }; var selection = ShowMenu(menuItems); while (selection != 16) { switch (selection) { case 1: var pets = _petService.GetPets(); ListPets(pets); break; case 2: var name = AskQuestion("What is the name of the pet? "); var previousOwner = AskQuestion("Who was the previous owner of the pet? "); var price = AskQuestion("What is the price of the pet? "); var soldDate = AskQuestion("When was the pet sold? "); var birthDate = AskQuestion("When was the pet born? "); var color = AskQuestion("What is the color of the pet? "); var pet = _petService.NewPet(name, previousOwner, Convert.ToDouble(price), Convert.ToDateTime(soldDate), Convert.ToDateTime(birthDate), color); _petService.CreatePet(pet); break; case 3: var idForDeletePet = PrintFindPetId(); _petService.DeletePet(idForDeletePet); break; case 4: var idForEdit = PrintFindPetId(); var petToEdit = _petService.FindPetById(idForEdit); Console.WriteLine("Updating " + petToEdit.Name); var newName = AskQuestion("What is the new name of pet? "); var newPreviousOwner = AskQuestion("Who was the previous Owner? "); var newPrice = AskQuestion("What is the new price of the pet? "); var newSoldDate = AskQuestion("When was it sold?"); var newBirthDate = AskQuestion("When was it born?"); var newColor = AskQuestion("What is the color of the pet?"); _petService.UpdatePet(new Pet() { ID = idForEdit, Name = newName, PreviousOwner = newPreviousOwner, Price = Convert.ToDouble(newPrice), SoldDate = Convert.ToDateTime(newBirthDate), BirthDate = Convert.ToDateTime(newBirthDate), Color = newColor }); break; case 5: var chosenType = AskQuestion("Insert type: "); var specifiedTypes = _typeService.getAllByType(chosenType); if (specifiedTypes != null) { ListTypes(specifiedTypes); } else { Console.WriteLine("No such type"); } break; case 6: var choice = AskQuestion("ASC or DESC: "); if (choice.Contains("ASC")) { ListPets(_petService.getASC()); } else { ListPets(_petService.getDESC()); } break; case 7: ListPets(_petService.getCheapest()); break; case 8: var firstName = AskQuestion("What is the first name of the customer? "); var lastName = AskQuestion("What is the last name of the customer? "); var birthDateOfCustomer = AskQuestion("What is the birthdate of the customer? "); var adress = AskQuestion("What is the adress of the customer? "); var newbirth = Convert.ToDateTime(birthDateOfCustomer); var customer = _customerService.NewCustomer(firstName, lastName, newbirth, adress); _customerService.CreateCustomer(customer); break; case 9: var idForDeleteCustomer = PrintFindCustomerId(); _customerService.DeleteCustomer(idForDeleteCustomer); break; case 10: var idForEditCustomer = PrintFindCustomerId(); var customerToEdit = _customerService.FindCustomerById(idForEditCustomer); Console.WriteLine("Updating " + customerToEdit.FirstName + customerToEdit.LastName); var newFirstName = AskQuestion("What is the new first name of customer? "); var newLastName = AskQuestion("What is the new last name of customer?"); var newBirthDateOfCustomer = AskQuestion("What is the new birthdate of customer? "); var newAdress = AskQuestion("What is the adress of the customer?"); _customerService.UpdateCustomer(new Customer() { ID = idForEditCustomer, FirstName = newFirstName, LastName = newLastName, BirthDateOfCustomer = Convert.ToDateTime(newBirthDateOfCustomer), Adress = newAdress, }); break; case 11: var customers = _customerService.GetCustomer(); ListCustomers(customers); break; case 12: var typetype = AskQuestion("What is the kind of pet? "); var TypeType = _typeService.NewType(typetype); _typeService.CreateType(TypeType); break; case 13: var idForDeleteType = PrintFindTypeId(); _typeService.DeleteType(idForDeleteType); break; case 14: var idForEditType = PrintFindTypeId(); var typeToEdit = _typeService.FindTypeById(idForEditType); Console.WriteLine("Updating " + typeToEdit); var newType = AskQuestion("What is the new name of the type of pet? "); _typeService.UpdateType(new Core.Type() { ID = idForEditType, TypeType = newType, }); break; case 15: var types = _typeService.GetTypes(); ListTypes(types); break; case 16: default: break; } selection = ShowMenu(menuItems); } Console.WriteLine("Have a blessed day. Bye and See you!"); Console.ReadLine(); }