// TODO: Shots Stuff
        internal static IQueryable <AnimalShot> GetShots(Animal animal)
        {
            var animalShots = db.AnimalShots.Where(s => s.AnimalId == animal.AnimalId);

            return(animalShots);
        }
 // TODO: Animal CRUD Operations
 internal static void AddAnimal(Animal animal)
 {
     db.Animals.InsertOnSubmit(animal);
     db.SubmitChanges();
 }
 internal static void RemoveAnimal(Animal animal)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
        // TODO: Shots Stuff
        internal static IQueryable <AnimalShot> GetShots(Animal animal)
        {
            IQueryable <AnimalShot> animalShots = db.AnimalShots.Where(c => c.AnimalId == animal.AnimalId);

            return(animalShots);
        }
Exemple #5
0
        internal static Animal GetAnimalByID(int id)
        {
            Animal animalById = db.Animals.Where(a => a.AnimalId >= id).First();

            return(animalById);
        }
        public void AddCSVFile(string fileName)
        {
            try
            {
                using (TextFieldParser parser = new TextFieldParser(@fileName))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");

                    while (!parser.EndOfData)
                    {
                        string[] animalTrait = parser.ReadFields();

                        Animal animalToAdd = new Animal();
                        animalToAdd.Name = animalTrait[0].Trim('"');
                        int?intParseValue = UserInterface.GetCsvIntData(animalTrait[2]);
                        animalToAdd.Weight = intParseValue;
                        string testedInput = UserInterface.CsvNullChecker(animalTrait[1]);
                        while (testedInput == null)
                        {
                            UserInterface.DisplayUserOptions("Please enter the animal`s species: ");
                            string input = Console.ReadLine();
                            intParseValue = Query.GetCategoryId(input);
                            if (intParseValue != null)
                            {
                                testedInput = "Not null";
                            }
                        }
                        animalToAdd.CategoryId = intParseValue;
                        intParseValue          = UserInterface.GetCsvIntData(animalTrait[3]);
                        animalToAdd.Age        = intParseValue;
                        intParseValue          = UserInterface.GetCsvIntData(animalTrait[4]);
                        animalToAdd.DietPlanId = intParseValue;
                        animalToAdd.Demeanor   = animalTrait[5].Trim('"');
                        bool?newFriendlyStatus = UserInterface.GetCsvBoolData(animalTrait[6]);
                        animalToAdd.KidFriendly    = newFriendlyStatus;
                        newFriendlyStatus          = UserInterface.GetCsvBoolData(animalTrait[7]);
                        animalToAdd.PetFriendly    = newFriendlyStatus;
                        animalToAdd.Gender         = animalTrait[8];
                        animalToAdd.AdoptionStatus = animalTrait[9].Trim('"');
                        intParseValue          = UserInterface.GetCsvIntData(animalTrait[10]);
                        animalToAdd.EmployeeId = intParseValue;

                        if (Query.CheckIfEmptyRoom())
                        {
                            Query.AddAnimal(animalToAdd);
                            Query.PlaceAnimalIntoRoom(animalToAdd.AnimalId);
                        }
                        else
                        {
                            UserInterface.DisplayUserOptions("There are no open rooms at this time. The animal has not been admitted. Press any key to continue.");
                            Console.ReadLine();
                            RunUserMenus();
                        }
                    }
                    RunUserMenus();
                }
            }
            catch
            {
                UserInterface.DisplayUserOptions("There is something wrong with the file you are attempting to load or the file does not exist. Please check it and try again. Press any key to continue.");
                Console.ReadLine();
                RunUserMenus();
            }
        }