Exemple #1
0
 public ActionResult List(Models.TeacherHonor.List vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("List", new
     {
         searchText = vm.SearchText,
         //TeacherId = vm.TeacherId,
         TeacherHonorLevelId = vm.TeacherHonorLevelId,
         TeacherHonorTypeId = vm.TeacherHonorTypeId
     })));
 }
Exemple #2
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.TeacherHonor.List();
                //vm.TeacherName = db.Set<Teacher.Entity.tbTeacher>().Find(vm.TeacherId).TeacherName;
                vm.TeacherHonorLevelList = TeacherHonorLevelController.SelectList();
                vm.TeacherHonorTypeList  = TeacherHonorTypeController.SelectList();
                var tb = db.Table <Teacher.Entity.tbTeacherHonor>().Where(d => d.tbTeacher.IsDeleted == false);

                #region 查询条件
                //tb = tb.Where(d => d.tbTeacher.Id == vm.TeacherId);
                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.HonorName.Contains(vm.SearchText) ||
                                  d.tbTeacher.TeacherName.Contains(vm.SearchText) ||
                                  d.tbTeacher.TeacherCode.Contains(vm.SearchText));
                }
                if (vm.TeacherHonorLevelId > 0)
                {
                    tb = tb.Where(d => d.tbTeacherHonorLevel.Id == vm.TeacherHonorLevelId);
                }
                if (vm.TeacherHonorTypeId > 0)
                {
                    tb = tb.Where(d => d.tbTeacherHonorType.Id == vm.TeacherHonorTypeId);
                }
                #endregion

                vm.DataList = (from p in tb
                               orderby p.No
                               select new Dto.TeacherHonor.List()
                {
                    Id = p.Id,
                    No = p.No,
                    TeacherId = p.tbTeacher.Id,
                    TeacherCode = p.tbTeacher.TeacherCode,
                    TeacherName = p.tbTeacher.TeacherName,
                    HonorName = p.HonorName,
                    HonorFile = p.HonorFile,
                    TeacherHonorLevelName = p.tbTeacherHonorLevel.TeacherHonorLevelName,
                    TeacherHonorTypeName = p.tbTeacherHonorType.TeacherHonorTypeName
                }).ToList();
                return(View(vm));
            }
        }