Exemplo n.º 1
0
        public ActionResult Details(int id = 0)
        {
            if (id == 0)
            {
                throw new Exception("课程不存在");
            }
            Course course = _courseService.GetByIdAsync(id);

            ViewBag.WorkList = _worksService.GetListByCourseIdAsync(id, 3) ?? new List <Instart.Models.Works>();
            List <Student> studentList = _studentService.GetListByCourseAsync(id) ?? new List <Instart.Models.Student>();
            //一行4个学员
            List <List <Student> > studentMap = new List <List <Student> >();
            int            studentIndex       = 1;
            List <Student> slist = new List <Student>();

            foreach (Student item in studentList)
            {
                slist.Add(item);
                if (studentIndex % 8 == 0)
                {
                    studentMap.Add(new List <Student>(slist.ToArray()));
                    slist.Clear();
                }
                studentIndex++;
            }
            if (slist.Count > 0)
            {
                studentMap.Add(slist);
            }
            ViewBag.StudentMap = studentMap;
            return(View(course ?? new Course()));
        }
Exemplo n.º 2
0
        public ActionResult Details(int id = 0)
        {
            if (id == 0)
            {
                throw new Exception("课程不存在");
            }
            Course course = _courseService.GetByIdAsync(id);

            ViewBag.WorkList    = _worksService.GetListByCourseIdAsync(id, 3) ?? new List <Instart.Models.Works>();
            ViewBag.StudentList = _studentService.GetListByCourseAsync(id) ?? new List <Instart.Models.Student>();
            return(View(course ?? new Course()));
        }