Ejemplo n.º 1
0
        public void FoodMenu()
        {
            var animals = new HumaneSocietyDB().Animals;

            foreach (var pet in animals)
            {
                Console.WriteLine("{0} eats {1} cups of {2} a day.", pet.PetName, pet.FoodAmount, pet.FoodType);
            }
        }
Ejemplo n.º 2
0
        public void RunEmployeeHumaneSociety()
        {
            HumaneSocietyDB db = new HumaneSocietyDB();
            string          option;
            bool            done = false;

            while (!done)
            {
                Console.WriteLine("What would you like to do? 'Find' an animal, 'add' an animal to the database, set an animal for 'adoption', collect a 'payment',  'vaccinate' an animal, import animals from 'CSV' file, evaluate animal 'food' needs, 'display' all animals, or 'done' to exit.");
                option = Console.ReadLine().ToLower();
                switch (option)
                {
                case "find":
                    SearchMenu();
                    break;

                case "food":
                    FoodMenu();
                    break;

                case "adoption":
                    ChangeAdoptionStatus();
                    break;

                case "payment":
                    PayForAnimal();
                    break;

                case "vaccinate":
                    VaccinateAnimal();
                    break;

                case "done":
                    done = true;
                    break;

                case "add":
                    db.Animals.Add(AddAnimal());
                    db.SaveChanges();
                    break;

                case "csv":
                    CSVReader cs = new CSVReader();
                    cs.CSVMenu(db);
                    break;

                case "display":
                    DisplayAnimals(db.Animals.ToList());
                    break;

                default:
                    Console.WriteLine("Sorry, '{0}' is not a valid entry. Try Again.", option);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public void CSVMenu(HumaneSocietyDB db)
        {
            Console.WriteLine("Welcome to the CSV reader.");
            Console.WriteLine("What would you like to do? 'Read' a csv file or change the 'filepath'?");
            switch (UI.GetStringInput())
            {
            case "filepath":
                Console.WriteLine("Enter your filepath:");
                filePath = "@" + UI.GetStringInput();
                break;

            case "read":
                Read(db);
                break;

            default:
                Console.WriteLine("Sorry, try again.");
                break;
            }
        }
Ejemplo n.º 4
0
 public void Read(HumaneSocietyDB db)
 {
     using (TextFieldParser parser = new TextFieldParser(filePath))
     {
         parser.TextFieldType = FieldType.Delimited;
         parser.SetDelimiters(",");
         while (!parser.EndOfData)
         {
             string[] fields = parser.ReadFields();
             Animal   animal = new Animal();
             animal.PetName        = fields[1];
             animal.AnimalType     = fields[0];
             animal.Size           = fields[2];
             animal.Gender         = fields[3];
             animal.BirthDate      = Convert.ToDateTime(fields[4]);
             animal.RoomID         = Convert.ToInt32(fields[5]);
             animal.FoodType       = fields[6];
             animal.FoodAmount     = Convert.ToInt32(fields[7]);
             animal.VaccineStatus  = fields[8];
             animal.AdoptionStatus = fields[9];
             UI.DisplayAnimal(animal);
             Console.WriteLine("Would you like to accept this entry to the database? 'Yes' or 'no'.");
             string input = UI.GetStringInput();
             if (input.ToLower() == "yes")
             {
                 try
                 {
                     db.Animals.Add(animal);
                     db.SaveChanges();
                 }
                 catch
                 {
                     Console.WriteLine("Sorry not enough rooms.");
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
        public void RunAdopterHumaneSociety()
        {
            HumaneSocietyDB db = new HumaneSocietyDB();
            string          option;
            bool            done = false;

            while (!done)
            {
                Console.WriteLine("What would you like to do? 'Find' an animal, Fill out 'Adopter' profile, 'Pay' for animal, or 'exit'");
                option = Console.ReadLine().ToLower();
                switch (option)
                {
                case "find":
                    SearchMenu();
                    break;

                case "adopter":
                    Adopter adopter = new Adopter();
                    db.People.Add(adopter.person);
                    db.SaveChanges();
                    break;

                case "pay":
                    PayForAnimal();
                    break;

                case "exit":
                    done = true;
                    break;

                default:
                    Console.WriteLine("Sorry, '{0}' is not a valid entry. Try Again.", option);
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        public void SearchMenu()
        {
            bool done;

            done = false;
            List <Animal> animals = new HumaneSocietyDB().Animals.ToList();

            while (!(animals.Count == 1) && !done)
            {
                Console.WriteLine("What would you like to filter by? 'Name', 'room', 'type', 'size', 'vaccination' status, 'adoption' status, or 'gender'.");
                switch (UI.GetStringInput().ToLower())
                {
                case "name":
                    Console.WriteLine("Enter name:");
                    animals = SearchByName(UI.GetStringInput(), animals);
                    DisplayAnimals(animals);
                    break;

                case "type":
                    Console.WriteLine("Enter animal type:");
                    animals = SearchByType(UI.GetStringInput(), animals);
                    DisplayAnimals(animals);
                    break;

                case "size":
                    Console.WriteLine("Enter size:");
                    animals = SearchBySize(UI.GetStringInput(), animals);
                    DisplayAnimals(animals);
                    break;

                case "vaccination":
                    Console.WriteLine("Is the animal you're looking for vaccinated? 'yes' or 'no'.");
                    animals = SearchByVaccineStatus(UI.GetStringInput(), animals);
                    DisplayAnimals(animals);
                    break;

                case "gender":
                    Console.WriteLine("Gender preferences");
                    animals = SearchByGender(UI.GetStringInput(), animals);
                    DisplayAnimals(animals);
                    break;

                case "adoption":
                    Console.WriteLine("Is the animal you're searching for 'adopted' or 'notadopted'?");
                    animals = SearchByAdoptionStatus(UI.GetStringInput(), animals);
                    DisplayAnimals(animals);
                    break;

                case "room":
                    Console.WriteLine("Which room is the animal in?");
                    animals = SearchByRoom(UI.GetIntInput(), animals);
                    DisplayAnimals(animals);
                    break;

                case "restart":
                    animals = new HumaneSocietyDB().Animals.ToList();
                    break;

                case "exit":
                    done = true;
                    break;

                default:
                    Console.WriteLine("Sorry that is an invalid input. Try Again.");
                    break;
                }
            }
        }
Ejemplo n.º 7
0
 //Constructor
 public HumaneSociety()
 {
     IntrinsicValueOfAnimals = 100;
     db = new HumaneSocietyDB();
     bb = new HumaneSocietyBankBox();
 }