Ejemplo n.º 1
0
 public ActionResult List(Models.ClassAllotStudent.List vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("List", new
     {
         searchText = vm.SearchText,
         yearId = vm.YearId,
         sexId = vm.SexId,
         classTypeId = vm.ClassTypeId,
         pageIndex = vm.Page.PageIndex,
         pageSize = vm.Page.PageSize
     })));
 }
Ejemplo n.º 2
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ClassAllotStudent.List();
                vm.YearList = YearController.SelectList(Code.EnumHelper.YearType.Year);
                if (vm.YearId == 0 && vm.YearList.Count > 0)
                {
                    vm.YearId = vm.YearList.OrderByDescending(d => d.Selected).FirstOrDefault().Value.ConvertToInt();
                }
                vm.ClassTypeList = ClassTypeController.SelectList();
                vm.SexList       = Dict.Controllers.DictSexController.SelectList();

                var tb = from p in db.Table <Basis.Entity.tbClassAllotStudent>()
                         where p.tbYear.Id == vm.YearId
                         select p;
                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.tbStudent.StudentName.Contains(vm.SearchText) || d.tbStudent.StudentCode.Contains(vm.SearchText));
                }
                if (vm.ClassTypeId != 0)
                {
                    tb = tb.Where(d => d.tbClassType.Id == vm.ClassTypeId);
                }
                if (vm.SexId != 0)
                {
                    tb = tb.Where(d => d.tbStudent.tbSysUser.tbSex.Id == vm.SexId);
                }

                vm.ClassAllotStudentList = (from p in tb
                                            orderby p.tbStudent.StudentCode, p.tbStudent.StudentName
                                            select new Dto.ClassAllotStudent.List
                {
                    Id = p.Id,
                    Score = p.Score,
                    ClassTypeName = p.tbClassType.ClassTypeName,
                    GradeName = p.tbGrade.GradeName,
                    StudentCode = p.tbStudent.StudentCode,
                    StudentName = p.tbStudent.StudentName,
                    Sex = p.tbStudent.tbSysUser.tbSex.SexName
                }).ToPageList(vm.Page);

                return(View(vm));
            }
        }