Beispiel #1
0
        public List <CourseMustafa> GetCourseDetails(int deptId)
        {
            Query   = "SELECT * FROM Course Where DepartmentId=@departmentId";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("departmentId", SqlDbType.Int);
            Command.Parameters["departmentId"].Value = deptId;
            Reader = Command.ExecuteReader();
            CourseMustafa        courseMustafa = null;
            List <CourseMustafa> courseList    = new List <CourseMustafa>();

            while (Reader.Read())
            {
                courseMustafa = new CourseMustafa()
                {
                    Code = Reader["Code"].ToString(),
                };

                courseList.Add(courseMustafa);
            }
            Reader.Close();
            Connection.Close();
            return(courseList);
        }
        public JsonResult GetCourseDetails(int courseId)
        {
            CourseMustafa courseMustafa = aCourseAssignManager.GetCourseDetails(courseId);


            return(Json(courseMustafa));
        }
        public List <CourseMustafa> GetAllCoursesByDeptId(int departmentId)
        {
            Query   = "SELECT * FROM Course Where DepartmentId = @id";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("id", SqlDbType.Int);
            Command.Parameters["id"].Value = departmentId;
            Reader = Command.ExecuteReader();
            List <CourseMustafa> courses = new List <CourseMustafa>();

            while (Reader.Read())
            {
                CourseMustafa courseMustafa = new CourseMustafa()
                {
                    Id   = (int)Reader["id"],
                    Name = Reader["Name"].ToString()
                };

                courses.Add(courseMustafa);
            }
            Reader.Close();
            Connection.Close();
            return(courses);
        }
Beispiel #4
0
        //public List<CourseMustafa> GetAllCourses()
        //{
        //    Query = "SELECT * FROM Course";
        //    Command = new SqlCommand(Query, Connection);
        //    Connection.Open();
        //    Reader = Command.ExecuteReader();
        //    List<CourseMustafa> courses = new List<CourseMustafa>();
        //    while (Reader.Read())
        //    {
        //        CourseMustafa aCourse = new CourseMustafa();
        //        aCourse.Id = (int)Reader["id"];
        //        aCourse.Name = Reader["Code"].ToString();
        //        courses.Add(aCourse);
        //    }
        //    Reader.Close();
        //    Connection.Close();
        //    return courses;
        //}

        public CourseMustafa GetCourseDetails(int courseId)
        {
            //Query = "SELECT * FROM Course";
            //Command = new SqlCommand(Query, Connection);
            //Connection.Open();
            //Reader = Command.ExecuteReader();

            //CourseMustafa aCourse = new CourseMustafa();
            //if (Reader.Read())
            //{
            //    aCourse.CourseId =courseId;
            //    aCourse.CourseName = Reader["Name"].ToString();
            //    aCourse.Credit = (decimal)Reader["Credit"];

            //}
            //Reader.Close();
            //Connection.Close();
            //return aCourse;

            Query   = "SELECT * FROM Course Where id = @courseId";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("courseId", SqlDbType.Int);
            Command.Parameters["courseId"].Value = courseId;
            Reader = Command.ExecuteReader();
            CourseMustafa courseMustafa = null;

            while (Reader.Read())
            {
                courseMustafa = new CourseMustafa()
                {
                    Name   = Reader["Name"].ToString(),
                    Credit = (decimal)Reader["Credit"]
                };
            }
            Reader.Close();
            Connection.Close();
            return(courseMustafa);
        }