Exemplo n.º 1
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ElectiveRule.List();
                vm.ElectiveName = db.Table <Entity.tbElective>().FirstOrDefault(d => d.Id == vm.ElectiveId).ElectiveName;

                var tb = from p in db.Table <Entity.tbElectiveRule>()
                         where p.tbElective.Id == vm.ElectiveId
                         select p;

                if (string.IsNullOrEmpty(vm.SearchText) == false)
                {
                    tb = tb.Where(d => d.tbCourse.CourseName.Contains(vm.SearchText));
                }

                vm.ElectiveRuleList = (from p in tb
                                       orderby p.No
                                       select new Dto.ElectiveRule.List
                {
                    Id = p.Id,
                    No = p.No,
                    CourseId = p.tbCourse.Id,
                    CourseName = p.tbCourse.CourseName,
                    CourseTarget = p.tbCourseTarget.CourseName,
                    ElectiveRule = p.ElectiveRule
                }).ToList();

                vm.CourseList = (from p in db.Table <Entity.tbElectiveOrg>()
                                 where p.tbElective.Id == vm.ElectiveId
                                 group p by new { p.tbCourse.Id, p.tbCourse.CourseCode, p.tbCourse.CourseName } into g
                                 select new Course.Dto.Course.SimpleInfo()
                {
                    Id = g.Key.Id,
                    CourseCode = g.Key.CourseCode,
                    CourseName = g.Key.CourseName
                }).ToList();
                return(View(vm));
            }
        }
Exemplo n.º 2
0
 public ActionResult List(Models.ElectiveRule.List vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("List", new { searchText = vm.SearchText, electiveId = vm.ElectiveId })));
 }