Exemplo n.º 1
0
 public ActionResult List(Models.ClassGroup.List vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("List", new
     {
         searchText = vm.SearchText,
         pageIndex = vm.Page.PageIndex,
         pageSize = vm.Page.PageSize
     })));
 }
Exemplo n.º 2
0
        public ActionResult List(int classId)
        {
            var vm = new Models.ClassGroup.List();

            vm.ClassId = classId;

            using (var db = new XkSystem.Models.DbContext())
            {
                var tb = db.Table <Basis.Entity.tbClassGroup>().Where(d => d.tbClass.Id == classId);
                var classStudentList = db.Table <Basis.Entity.tbClassStudent>()
                                       .Include(d => d.tbClassGroup)
                                       .Where(d => d.tbClass.Id == vm.ClassId).ToList();

                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.ClassGroupName.Contains(vm.SearchText));
                }

                vm.ClassGroupList = (from p in tb
                                     orderby p.No
                                     select new Dto.ClassGroup.List()
                {
                    Id = p.Id,
                    No = p.No,
                    ClassGroupName = p.ClassGroupName,
                    TeacherCode = p.tbTeacher.TeacherCode,
                    TeacherName = p.tbTeacher.TeacherName
                }).ToPageList(vm.Page);

                foreach (var v in vm.ClassGroupList)
                {
                    v.StudentCount = classStudentList.Where(d => d.tbClassGroup != null && d.tbClassGroup.Id == v.Id).Count();
                }
            }

            return(View(vm));
        }