Exemplo n.º 1
0
        public ActionResult Details(int id)
        {
            var major = _majorService.GetByIdAsync(id);

            if (major == null)
            {
                throw new Exception("专业不存在");
            }

            ViewBag.WorkList = (_workService.GetListByMajorIdAsync(id, 3)) ?? new List <Instart.Models.Works>();
            //ViewBag.CourseList = _courseService.GetListByMajor(3, id) ?? new List<Course>();

            IEnumerable <Student> studentList   = (_studentService.GetAllAsync()) ?? new List <Student>();
            List <Student>        majorStudents = new List <Student>();

            foreach (Student student in studentList)
            {
                if (student.MajorId == id)
                {
                    majorStudents.Add(student);
                }
            }
            ViewBag.MajorStudents = majorStudents;
            return(View(major));
        }
Exemplo n.º 2
0
        public ActionResult Details(int id)
        {
            var major = _majorService.GetByIdAsync(id);

            if (major == null)
            {
                throw new Exception("专业不存在");
            }

            ViewBag.WorkList = (_workService.GetListByMajorIdAsync(id, 3)) ?? new List <Instart.Models.Works>();
            List <School> schoolList = _schoolService.GetListByMajorAsync(id, 6) ?? new List <Instart.Models.School>();
            //计算录取比例
            IEnumerable <Student> studentList = (_studentService.GetAllAsync()) ?? new List <Student>();

            foreach (School school in schoolList)
            {
                int count = 0;
                foreach (Student student in studentList)
                {
                    if (student.SchoolId == school.Id)
                    {
                        count++;
                    }
                }
                school.AcceptRate = "0";
                if (studentList.Count() > 0)
                {
                    decimal rate = (decimal)count / studentList.Count();
                    school.AcceptRate = (rate * 100).ToString("f2");
                }
            }
            ViewBag.SchoolList = schoolList;
            return(View(major));
        }
Exemplo n.º 3
0
        public ActionResult Details(int id = 0)
        {
            if (id == 0)
            {
                throw new Exception("课程不存在");
            }
            Course course = _courseService.GetByIdAsync(id);

            ViewBag.WorkList    = _worksService.GetListByMajorIdAsync(id, 3) ?? new List <Instart.Models.Works>();
            ViewBag.StudentList = _studentService.GetListByCourseAsync(id) ?? new List <Instart.Models.Student>();
            return(View(course ?? new Course()));
        }
Exemplo n.º 4
0
        public ActionResult Details(int id)
        {
            var major = _majorService.GetByIdAsync(id);

            if (major == null)
            {
                throw new Exception("专业不存在");
            }

            ViewBag.WorkList   = (_workService.GetListByMajorIdAsync(id, 3)) ?? new List <Instart.Models.Works>();
            ViewBag.BannerList = (_bannerService.GetBannerListByPosAsync(Instart.Models.Enums.EnumBannerPos.Teacher)) ?? new List <Instart.Models.Banner>();
            return(View(major));
        }