Example #1
0
        public void ChangeAdoptionStatus()
        {
            Console.WriteLine("What is the AnimalID of the Animal being adopted?");
            int    input  = UI.GetIntInput();
            Animal animal = db.Animals.Single(n => n.ID == input);

            animal.AdoptionStatus = "adopted";
            db.SaveChanges();
        }
Example #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;
                }
            }
        }
Example #3
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.");
                 }
             }
         }
     }
 }
Example #4
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;
                }
            }
        }