Exemple #1
0
        /// <summary>
        /// Fill the Studnet Entity by using sql reader of command
        /// </summary>
        /// <param name="sqlCommand">sql command object for excute reader</param>
        /// <returns>colletion of students</returns>
        private static List <Student> FillStudentEntity(SqlCommand sqlCommand)
        {
            var locationList = new LocationDAL().GetLocations();
            var levelsList   = new LevelDAL().GetLevels();

            List <Student> students = new List <Student>();

            using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
            {
                while (sqlDataReader.Read())
                {
                    int locationID = Convert.ToInt32(sqlDataReader["LocationID"]);
                    students.Add(new Student
                    {
                        StudentId  = Convert.ToInt32(sqlDataReader["StudentID"]),
                        FirstName  = sqlDataReader["FirstName"].ToString(),
                        LastName   = sqlDataReader["LastName"].ToString(),
                        Email      = sqlDataReader["Email"].ToString(),
                        Address1   = sqlDataReader["Address1"].ToString(),
                        Address2   = sqlDataReader["Address2"].ToString(),
                        City       = sqlDataReader["City"].ToString(),
                        Zip        = sqlDataReader["Zip"].ToString(),
                        DOB        = Convert.ToDateTime(sqlDataReader["DOB"]?.ToString()),
                        State      = sqlDataReader["State"].ToString(),
                        LocationID = Convert.ToInt32(sqlDataReader["LocationID"]),
                        Locations  = locationList,
                        LevelID    = Convert.ToInt32(sqlDataReader["LevelID"]),
                        Levels     = levelsList,
                        IsDelted   = Convert.ToBoolean(sqlDataReader["IsDeleted"])
                    });
                }
            }
            return(students);
        }
Exemple #2
0
        /// <summary>
        /// Fill the Studnet Entity by using sql reader of command
        /// </summary>
        /// <param name="sqlCommand">sql command object for excute reader</param>
        /// <returns>colletion of students</returns>
        private static List <SkillLevel> FillSkillLevel(SqlCommand sqlCommand)
        {
            List <Location> loc = new List <Location>();

            loc = new LocationDAL().GetLocations();

            List <SkillLevel> skillLevels = new List <SkillLevel>();

            using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
            {
                while (sqlDataReader.Read())
                {
                    int skillLevelID = Convert.ToInt32(sqlDataReader["SkillLevelID"]);
                    int levelID      = Convert.ToInt32(sqlDataReader["LevelID"]);
                    int skillID      = Convert.ToInt32(sqlDataReader["SkillID"]);
                    var levelsList   = new LevelDAL().GetLevels();
                    var skillsList   = new SkillDAL().GetSkills();

                    //int locationID = Convert.ToInt32(sqlDataReader["LocationID"]);
                    skillLevels.Add(new SkillLevel
                    {
                        SkillLevelID = skillLevelID,
                        LevelID      = levelID,
                        SkillID      = skillID,
                        LevelInfo    = levelsList.FirstOrDefault(x => x.LevelID == levelID),
                        SkillInfo    = skillsList.FirstOrDefault(x => x.SkillID == skillID),
                        SortOrder    = Convert.ToInt32(sqlDataReader["SortOrder"])
                    });
                }
            }
            return(skillLevels);
        }