public ActionResult Index(DepartmentViewhelper departmentViewhelper)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_HETHONG, Session.getCurrentUser().username, TypeAudit.CoCauToChuc))
     {
         return Redirect("/admin/error/error403");
     }
     saveData(departmentViewhelper);
     return View();
 }
 public List<gov_department> setSearchFilter(List<gov_department> lstDepartment, DepartmentViewhelper departmentViewhelper)
 {
     if (!String.IsNullOrWhiteSpace(departmentViewhelper.KeySearch)) { }
     return lstDepartment;
 }
        public DepartmentViewhelper saveData(DepartmentViewhelper departmentViewhelper)
        {
            List<gov_department> lstDepartment = _cnttDB.gov_department.ToList();
            lstDepartment = setSearchFilter(lstDepartment, departmentViewhelper);

            int totalCount = lstDepartment.Count;
            departmentViewhelper.TotalCount = totalCount;

            if (departmentViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                departmentViewhelper.TotalPage = totalPage;
                departmentViewhelper.Page = pageTransition(departmentViewhelper.Direction, departmentViewhelper.Page, totalPage);
                departmentViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, departmentViewhelper.Page);
                departmentViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, departmentViewhelper.Page, departmentViewhelper.FirstPage);
                int take = Constant.limit;
                int skip = (departmentViewhelper.Page - 1) * take;
                departmentViewhelper.LstDepartment = lstDepartment.OrderBy(d => d.order_number).Skip(skip).Take(take).ToList();
            }
            ViewData["departmentViewhelper"] = departmentViewhelper;
            return departmentViewhelper;
        }