Beispiel #1
0
        /**********************
        * Get all classes taught by instructor id
        **********************/
        public List <ClassDetails> GetClassDetailsByInstructor(int id)
        {
            Connection();
            List <ClassDetails> classlist = new List <ClassDetails>();

            SqlCommand cmd = new SqlCommand("Project.GetFullClassDetailsFromInstructor", con)
            {
                CommandType = CommandType.StoredProcedure
            };

            cmd.Parameters.AddWithValue("@InstructorId", id);
            SqlDataAdapter sd = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();


            con.Open();
            sd.Fill(dt);
            con.Close();

            foreach (DataRow dr in dt.Rows)
            {
                classlist.Add(
                    new ClassDetails
                {
                    ClassId    = Convert.ToInt32(dr["ClassId"]),
                    ClassName  = Convert.ToString(dr["ClassName"]),
                    Building   = Convert.ToString(dr["Building"]),
                    Days       = ClassDetails.ConvertBitsToDays(Convert.ToInt32(dr["Days"])),
                    FirstName  = Convert.ToString(dr["FirstName"]),
                    LastName   = Convert.ToString(dr["LastName"]),
                    StartTime  = TimeSpan.Parse(Convert.ToString(dr["StartTime"])),
                    EndTime    = TimeSpan.Parse(Convert.ToString(dr["EndTime"])),
                    TermName   = Convert.ToString(dr["TermName"]),
                    RoomNumber = Convert.ToInt32(dr["RoomNumber"])
                });
            }
            return(classlist);
        }
Beispiel #2
0
        public List <ClassDetails> GetFilteredClasses(string firstName, string lastName, string department, string days, string startTime, string endTime, string termName, string termYear, string type)
        {
            Connection();
            List <ClassDetails> classlist = new List <ClassDetails>();

            SqlCommand cmd = new SqlCommand("Project.GetFilteredClasses", con)
            {
                CommandType = CommandType.StoredProcedure
            };

            if (department != "")
            {
                cmd.Parameters.AddWithValue("@Department", department);
            }
            if (firstName != "")
            {
                cmd.Parameters.AddWithValue("@FirstName", firstName);
            }
            if (lastName != "")
            {
                cmd.Parameters.AddWithValue("@LastName", lastName);
            }
            if (startTime != "")
            {
                cmd.Parameters.AddWithValue("@StartTime", startTime);
            }
            if (endTime != "")
            {
                cmd.Parameters.AddWithValue("@EndTime", endTime);
            }
            if (days != "")
            {
                cmd.Parameters.AddWithValue("@Days", ClassDetails.ConvertDaysToBits(days));
            }
            if (termName != "")
            {
                cmd.Parameters.AddWithValue("@TermName", termName);
            }
            if (termYear != "")
            {
                cmd.Parameters.AddWithValue("@TermYear", termYear);
            }
            if (type != "")
            {
                cmd.Parameters.AddWithValue("@Type", type);
            }

            SqlDataAdapter sd = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            con.Open();
            sd.Fill(dt);
            con.Close();
            foreach (DataRow dr in dt.Rows)
            {
                classlist.Add(
                    new ClassDetails
                {
                    ClassName  = Convert.ToString(dr["ClassName"]),
                    ClassId    = Convert.ToInt32(dr["ClassId"]),
                    FirstName  = Convert.ToString(dr["FirstName"]),
                    LastName   = Convert.ToString(dr["LastName"]),
                    TermName   = Convert.ToString(dr["TermName"]),
                    Days       = ClassDetails.ConvertBitsToDays(Convert.ToInt32(dr["Days"])),
                    StartTime  = TimeSpan.Parse(Convert.ToString(dr["StartTime"])),
                    EndTime    = TimeSpan.Parse(Convert.ToString(dr["EndTime"])),
                    Building   = Convert.ToString(dr["Building"]),
                    RoomNumber = Convert.ToInt32(dr["RoomNumber"])
                });
            }
            return(classlist);
        }
 public ClassReviewViewModel(ClassDetails cmodel, List <Review> reviews)
 {
     ClassModel   = cmodel;
     ReviewsModel = reviews;
 }