Beispiel #1
0
        public List <AbstractPerson> DisplayAllStudentsFromACursusId(int cursusId)
        {
            List <AbstractPerson> studentsOfASameCursus = new List <AbstractPerson>();

            SqlCommand cmd = new SqlCommand("sp_DisplayAllStudentsFromACursus", Connection);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@CursusId", SqlDbType.VarChar).Value = cursusId;

            Cursus cursus = Database.GetInstance().GetCursusFromId(cursusId);

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                int      personId        = reader.GetInt32(0);
                string   personFirstName = reader.GetString(1);
                string   personLastName  = reader.GetString(2);
                string   personEmail     = reader.GetString(3);
                DateTime personBirthday  = reader.GetDateTime(4);
                int      streetNumber    = reader.GetInt32(5);
                string   streetName      = reader.GetString(6);
                string   city            = reader.GetString(7);
                string   country         = reader.GetString(8);


                Adress         adress = new Adress(streetNumber, streetName, city, country);
                AbstractPerson person = PersonFactory.Create();
                // set Person properties independently
                studentsOfASameCursus.Add(person);
            }
            reader.Close();


            return(studentsOfASameCursus);
        }