public ActionResult Index(StudentViewhelper studentViewhelper) { if (Session.getCurrentUser() == null) return Redirect("/admin/account/logon"); if (!SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, Session.getCurrentUser().username, TypeAudit.ManagerStudent)) { return Redirect("/admin/error/error403"); } saveData(studentViewhelper); return View(); }
public void saveStudentData(StudentViewhelper studentViewhelper) { List<gov_person> lstStudent = _cnttDB.gov_person.Where(u => u.active_flg == true).ToList(); lstStudent = setSearchFilterStudent(lstStudent, studentViewhelper); int totalCount = lstStudent.Count; studentViewhelper.TotalCount = totalCount; if (studentViewhelper.TotalCount > 0) { int totalPage = pageCalculation(totalCount, Constant.limit); studentViewhelper.TotalPage = totalPage; studentViewhelper.Page = pageTransition(studentViewhelper.Direction, studentViewhelper.Page, totalPage); studentViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, studentViewhelper.Page); studentViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, studentViewhelper.Page, studentViewhelper.FirstPage); int take = Constant.limit; int skip = (studentViewhelper.Page - 1) * take; studentViewhelper.LstStudent = lstStudent.OrderByDescending(u => u.entry_datetime).Skip(skip).Take(take).ToList(); } studentViewhelper.LstCourse = _cnttDB.gov_course.OrderByDescending(c => c.course_name).ToList(); studentViewhelper.LstSpecialized = _cnttDB.gov_specialized.OrderBy(s => s.specialized_name).ToList(); ViewData["studentViewhelper"] = studentViewhelper; }
public List<gov_person> setSearchFilterStudent(List<gov_person> lststudent, StudentViewhelper studentViewhelper) { Expression<Func<gov_person, bool>> predicate = PredicateBuilder.False<gov_person>(); if (studentViewhelper.CourseFilter > 0) { lststudent = lststudent.Where(n => n.course_id == studentViewhelper.CourseFilter).ToList(); } if (studentViewhelper.SpecializedFilter > 0) { lststudent = lststudent.Where(n => n.specialized_id == studentViewhelper.SpecializedFilter).ToList(); } if (!String.IsNullOrWhiteSpace(studentViewhelper.KeySearch)) { predicate = predicate.Or(d => d.full_name != null && d.full_name.ToUpper().Contains(studentViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.lop != null && d.lop.ToUpper().Contains(studentViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.email != null && d.email.ToUpper().Contains(studentViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.phone != null && d.phone.ToUpper().Contains(studentViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.department != null && d.department.ToUpper().Contains(studentViewhelper.KeySearch.ToUpper())); predicate = predicate.Or(d => d.address != null && d.address.ToUpper().Contains(studentViewhelper.KeySearch.ToUpper())); lststudent = lststudent.Where(predicate.Compile()).ToList(); } return lststudent; }
public ActionResult Index(StudentViewhelper studentViewhelper) { saveStudentData(studentViewhelper); return View(); }
public ActionResult Index() { StudentViewhelper studentViewhelper = new StudentViewhelper(); saveStudentData(studentViewhelper); return View(); }