Beispiel #1
0
        public static void AddCvsInfoToSql()
        {
            var csvFile = GetCvsFileInfo("animals.csv");

            foreach (var item in csvFile)
            {
                Animal animal = new Animal();
                animal.Name           = item[0];
                animal.Weight         = Convert.ToInt32(item[1]);
                animal.Age            = Convert.ToInt32(item[2]);
                animal.Demeanor       = item[3];
                animal.KidFriendly    = UserInterface.ConvertToBool(item[4]);
                animal.PetFriendly    = UserInterface.ConvertToBool(item[5]);
                animal.Gender         = item[6];
                animal.AdoptionStatus = item[7];
                if (CheckIfAlreadyInDB(animal) == false)
                {
                    AddAnimal(animal);
                }
            }
        }