public void display() { Console.Clear(); Console.WriteLine(name); Console.WriteLine(seperator); actionator.go(); Console.WriteLine(seperator); InputAsker.anyKeyInput("Press any key to return"); }
public void go() { try { int id = InputAsker.AskForNumericInput("Enter the id of the pet you want to delete:"); Console.WriteLine("\n Pet:" + _petService.DeletePet(id) + " was Created"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void go() { try { string name = InputAsker.AskForTextInput("Enter Name, Must be more than 3 characters long:"); foreach (var item in _petService.getPetTypeInSortedList()) { Console.WriteLine("[" + item.Key + "] - " + item.Value.ToString()); } int iType = InputAsker.AskForNumericInput("Pleace select the Pet Type"); var type = _petService.getPetTypeInSortedList()[iType]; DateTime bDay = InputAsker.AskForDate("Enter Birth Day:"); String color = InputAsker.AskForTextInput("Enter Color:"); double price = InputAsker.AskForNumericInput("Enter Price:"); Owner previousOwner = _ownerService.ReadOwner(InputAsker.AskForNumericInput("Enter id of owner")); Pet newPet = new Pet { Name = name, PType = type, BirthDate = bDay, Price = price, //PriviousOwner = previousOwner, Color = color }; Console.WriteLine("\nPet:" + _petService.CreatePet(newPet) + " was Created"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void go() { try { SortedList <int, PetType.PType> types = _petService.getPetTypeInSortedList(); foreach (var item in _petService.getPetTypeInSortedList()) { Console.WriteLine("[" + item.Key + "] - " + item.Value.ToString()); } bool valid = false; int input = InputAsker.AskForNumericInput("Choose a type to seach by."); while (!valid) { if (input < _petService.getPetTypeInSortedList().Count&& input > 0) { valid = true; } else { Console.WriteLine("There is no Type with the choosen numeric value"); input = InputAsker.AskForNumericInput("\nChoose a type to seach by."); } } PetType.PType type = types[input]; List <Pet> petsByType = _petService.SeachByType(type); Console.WriteLine("--------------------------------------------------------"); foreach (var item in petsByType) { Console.WriteLine(item); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public void go() { Owner owner = null; while (owner == null) { int id = AskForNumericInput("Please Enter the id of the movie you want to update."); owner = _ownerService.ReadOwner(id); if (owner == null) { Console.WriteLine(" is not a Valid ID! Try again!"); } } bool done = false; while (!done) { Console.Clear(); Console.WriteLine("Pet found: " + owner.ToString()); Console.WriteLine("--------------------------------------------------------"); Console.WriteLine( "[1] - Edit First Name\n" + "[2] - Edit Last Name\n" + "[3] - Edit Adress\n" + "[4] - Edit Phone Number\n" + "[5] - Edit Email\n" + "\n[9] - Edit All\n" + "[0] - done\n" ); int input; while (!int.TryParse(Console.ReadKey().KeyChar.ToString(), out input)) { Console.WriteLine(" is not a Valid Input! Try again!"); } if (checkIfValid(input)) { switch (input) { case 1: Console.Clear(); owner.FirstName = AskForTextInput("Enter First Name:"); break; case 2: Console.Clear(); owner.LastName = AskForTextInput("Enter Last Name:"); break; case 3: Console.Clear(); owner.Address = AskForTextInput("Enter Adress:"); break; case 4: Console.Clear(); owner.PhoneNumber = AskForTextInput("Enter PhoneNumber Name:"); break; case 5: Console.Clear(); owner.Email = AskForTextInput("Enter Email:"); break; case 9: Console.Clear(); string firstname = AskForTextInput("Enter First Name:"); string lastName = AskForTextInput("Enter Last Name:"); string address = AskForTextInput("Enter Adress:"); string phoneNumber = AskForTextInput("Enter PhoneNumber Name:"); string email = AskForTextInput("Enter Email:"); owner = new Owner { FirstName = firstname, LastName = lastName, Address = address, PhoneNumber = phoneNumber, Email = email }; break; case 0: try { _ownerService.UpdateOwner(owner); done = true; Console.Clear(); Console.WriteLine("\nThe Owner: " + owner + " was Updated"); } catch (Exception e) { Console.WriteLine("\n" + e.Message); Console.WriteLine("The Owner was not updated."); InputAsker.anyKeyInput("Press any key to return"); } break; default: break; } } else { Console.WriteLine(" is not a Valid Input! Try again!"); } } }
public void go() { Pet pet = null; while (pet == null) { int id = InputAsker.AskForNumericInput("Please Enter the id of the movie you want to update."); pet = _petService.ReadPetByID(id); if (pet == null) { Console.WriteLine(" is not a Valid ID! Try again!"); } } bool done = false; while (!done) { Console.Clear(); Console.WriteLine("Pet found: " + pet.ToString()); Console.WriteLine("--------------------------------------------------------"); Console.WriteLine( "[1] - Edit Name\n" + "[2] - Edit Type\n" + "[3] - Edit Birthday\n" + "[4] - Edit Color\n" + "[5] - Edit Price\n" + "[6] - Edit Previous Owner\n" + "[7] - Edit Sold Date\n" + "\n[9] - Edit All\n" + "[0] - done\n" ); int input; while (!int.TryParse(Console.ReadKey().KeyChar.ToString(), out input)) { Console.WriteLine(" is not a Valid Input! Try again!"); } if (checkIfValid(input)) { switch (input) { case 1: Console.Clear(); pet.Name = InputAsker.AskForTextInput("Please enter new Title:"); break; case 2: Console.Clear(); foreach (var item in _petService.getPetTypeInSortedList()) { Console.WriteLine("[" + item.Key + "] - " + item.Value.ToString()); } int iType = InputAsker.AskForNumericInput("Pleace select the Pet Type"); pet.PType = _petService.getPetTypeInSortedList()[iType]; break; case 3: Console.Clear(); pet.BirthDate = InputAsker.AskForDate("Enter Birth Day:"); break; case 4: Console.Clear(); pet.Color = InputAsker.AskForTextInput("Enter Color:"); break; case 5: Console.Clear(); pet.Price = InputAsker.AskForNumericInput("Enter Price:"); break; case 6: Console.Clear(); //pet.PriviousOwner = _ownerService.ReadOwner(InputAsker.AskForNumericInput("Enter id of owner")); break; case 7: Console.Clear(); pet.SoldDate = InputAsker.AskForDate("Enter Sold Date:"); break; case 9: Console.Clear(); string name = InputAsker.AskForTextInput("Enter Name, Must be more than 3 characters long:"); foreach (var item in _petService.getPetTypeInSortedList()) { Console.WriteLine("[" + item.Key + "] - " + item.Value.ToString()); } int iType2 = InputAsker.AskForNumericInput("Pleace select the Pet Type"); var type2 = _petService.getPetTypeInSortedList()[iType2]; DateTime birthDate = InputAsker.AskForDate("Enter Birth Day:"); String color2 = InputAsker.AskForTextInput("Enter Color:"); double price2 = InputAsker.AskForNumericInput("Enter Price:"); Owner previousOwner2 = _ownerService.ReadOwner(InputAsker.AskForNumericInput("Enter id of owner")); DateTime soldDate = InputAsker.AskForDate("Enter Sold Date:"); pet = new Pet { Name = name, PType = type2, BirthDate = birthDate, Price = price2, //PriviousOwner = previousOwner2, Color = color2, SoldDate = soldDate }; break; case 0: try { _petService.UpdatePet(pet); done = true; Console.Clear(); Console.WriteLine("\n The Pet:\n" + pet + " \nWas succesfully Updated."); } catch (Exception e) { Console.WriteLine("\n" + e.Message); Console.WriteLine("The Pet was not updated."); InputAsker.anyKeyInput("Press any key to return"); } break; default: break; } } else { Console.WriteLine(" is not a Valid Input! Try again!"); } } bool checkIfValid(int input) { foreach (int validInput in _validInputs) { if (validInput == input) { return(true); } } return(false); } }