Beispiel #1
0
        /// <summary>
        /// 课程查看列表
        /// </summary>
        public ActionResult InfoList()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.Course.InfoList();

                var tb = (from p in db.Table <Entity.tbCourse>() select p);

                if (vm.TypeId > 0)
                {
                    tb = tb.Where(p => p.tbCourseType.Id == vm.TypeId);
                }

                if (vm.GroupId > 0)
                {
                    tb = tb.Where(p => p.tbCourseGroup.Id == vm.GroupId);
                }
                if (vm.DomainId > 0)
                {
                    tb = tb.Where(p => p.tbCourseDomain.Id == vm.DomainId);
                }
                if (vm.SubjectId > 0)
                {
                    tb = tb.Where(p => p.tbSubject.Id == vm.SubjectId);
                }

                vm.CourseInfoList = (from p in tb
                                     orderby p.No
                                     select new Dto.Course.InfoList()
                {
                    Id = p.Id,
                    CourseName = p.CourseName,
                    CourseNameEn = p.CourseNameEn,
                    CourseTypeName = p.tbCourseType.CourseTypeName,
                    SubjectName = p.tbSubject.SubjectName,
                    Point = p.Point,
                    Hour = p.Hour,
                    CourseCode = p.CourseCode,
                    CourseDomainName = p.tbCourseDomain != null ? p.tbCourseDomain.CourseDomainName : string.Empty,
                    CourseGroupName = p.tbCourseGroup != null ? p.tbCourseGroup.CourseGroupName : string.Empty
                }).ToList();

                vm.CourseSubjectList = SubjectController.SelectList();
                vm.CourseDomainList  = CourseDomainController.SelectList();
                vm.CourseGroupList   = CourseGroupController.SelectList();
                vm.CourseTypeList    = CourseTypeController.SelectList();

                return(View(vm));
            }
        }
Beispiel #2
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.Course.List();
                vm.SubjectList      = SubjectController.SelectList();
                vm.CourseTypeList   = CourseTypeController.SelectList();
                vm.CourseDomainList = CourseDomainController.SelectList();
                vm.CourseGroupList  = CourseGroupController.SelectList();

                var tb = from p in db.Table <Course.Entity.tbCourse>()
                         select p;
                if (string.IsNullOrEmpty(vm.SearchText) == false)
                {
                    tb = tb.Where(d => d.CourseName.Contains(vm.SearchText));
                }

                if (vm.SubjectId != 0)
                {
                    tb = tb.Where(d => d.tbSubject.Id == vm.SubjectId);
                }

                if (vm.CourseTypeId != 0)
                {
                    tb = tb.Where(d => d.tbCourseType.Id == vm.CourseTypeId);
                }

                if (vm.CourseDomainId != 0)
                {
                    tb = tb.Where(d => d.tbCourseDomain.Id == vm.CourseDomainId);
                }

                if (vm.CourseGroupId != 0)
                {
                    tb = tb.Where(d => d.tbCourseGroup.Id == vm.CourseGroupId);
                }

                vm.CourseSubjectList = (from p in tb
                                        orderby p.tbSubject.No
                                        select new Dto.Subject.Info
                {
                    Id = p.tbSubject.Id,
                    SubjectName = p.tbSubject.SubjectName
                }).Distinct().ToList();

                vm.CourseList = (from p in tb
                                 orderby
                                 p.tbCourseDomain.No, p.tbCourseDomain.CourseDomainName,
                                 p.tbSubject.No, p.tbSubject.SubjectName, p.CourseCode, p.CourseName
                                 select new Dto.Course.List
                {
                    Id = p.Id,
                    CourseName = p.CourseName,
                    CourseNameEn = p.CourseNameEn,
                    CourseTypeName = p.tbCourseType.CourseTypeName,
                    SubjectName = p.tbSubject.SubjectName,
                    Point = p.Point,
                    Hour = p.Hour,
                    CourseCode = p.CourseCode,
                    CourseDomainName = p.tbCourseDomain.CourseDomainName,
                    CourseGroupName = p.tbCourseGroup.CourseGroupName,
                    IsLevel = p.IsLevel
                }).ToList();
                return(View(vm));
            }
        }