public ActionResult Index()
 {
     DocumentViewhepler docViewhelper = new DocumentViewhepler();
     docViewhelper.TypeSearch = 1;
     saveData(docViewhelper);
     return View();
 }
        public void saveData(DocumentViewhepler docViewhelper)
        {
            List<gov_doc_draft> lstDocument = _cnttDB.gov_doc_draft.Where(d => d.doc_type == true).ToList();
            int totalCount = lstDocument.Count;
            docViewhelper.TotalCount = totalCount;

            if (docViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                docViewhelper.TotalPage = totalPage;
                docViewhelper.Page = pageTransition(docViewhelper.Direction, docViewhelper.Page, totalPage);
                docViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, docViewhelper.Page);
                docViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, docViewhelper.Page, docViewhelper.FirstPage);
                int take = Constant.limit;
                int skip = (docViewhelper.Page - 1) * take;
                docViewhelper.LstDocument = lstDocument.OrderByDescending(d => d.update_datetime).Skip(skip).Take(take).ToList();
            }
            ViewData["docViewhelper"] = docViewhelper;
        }
        public ActionResult Index(DocumentViewhepler viewHelper)
        {
            
            if (!String.IsNullOrWhiteSpace(viewHelper.KeySearch))
            {
                List<gov_doc_draft> lstResult = new List<gov_doc_draft>();
                var lucene = new LuceneSerives.LuceneDocuments();
                if (viewHelper.TypeSearch == 1)
                {
                    lstResult = lucene.SearchAdvanced(viewHelper.KeySearch, Boolean.TrueString, "doc_full_text").ToList();
                }
                else
                {
                    lstResult = lucene.SearchAdvanced(viewHelper.KeySearch, Boolean.TrueString, "doc_code_and_summany").ToList();
                }

                int totalCount = lstResult.Count;
                viewHelper.TotalCount = totalCount;
                if (totalCount > 0)
                {
                    int totalPage = pageCalculation(totalCount, Constant.limit);
                    viewHelper.TotalPage = totalPage;
                    viewHelper.Page = pageTransition(viewHelper.Direction, viewHelper.Page, totalPage);
                    viewHelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, viewHelper.Page);
                    viewHelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, viewHelper.Page, viewHelper.FirstPage);
                    int take = Constant.limit;
                    int skip = (viewHelper.Page - 1) * take;
                    viewHelper.LstDocument = lstResult.OrderBy(d => d.score).Skip(skip).Take(take).ToList();
                }
            }
            else
            {
                saveData(viewHelper);
            }

            ViewData["docViewhelper"] = viewHelper;
            return View();
        }
 public List<gov_doc_draft> setSearchFilter(List<gov_doc_draft> lstDocument, DocumentViewhepler documentViewhepler)
 {
     Expression<Func<gov_doc_draft, bool>> predicate = PredicateBuilder.False<gov_doc_draft>();
     if (!String.IsNullOrWhiteSpace(documentViewhepler.KeySearch))
     {
         predicate = predicate.Or(d => d.doc_code != null && d.doc_code.ToUpper().Contains(documentViewhepler.KeySearch.ToUpper()));
         predicate = predicate.Or(d => d.doc_name != null && d.doc_name.ToUpper().Contains(documentViewhepler.KeySearch.ToUpper()));
         predicate = predicate.Or(d => d.doc_summany!= null && d.doc_summany.ToUpper().Contains(documentViewhepler.KeySearch.ToUpper()));
         predicate = predicate.Or(d => d.user_sign!= null && d.user_sign.ToUpper().Contains(documentViewhepler.KeySearch.ToUpper()));
         lstDocument = lstDocument.Where(predicate.Compile()).ToList();
     }
     return lstDocument;
 }
        public DocumentViewhepler saveData(DocumentViewhepler documentViewhepler)
        {
            List<gov_doc_draft> lstDocument = _cnttDB.gov_doc_draft.ToList();
            lstDocument = setSearchFilter(lstDocument, documentViewhepler);

            int totalCount = lstDocument.Count;
            documentViewhepler.TotalCount = totalCount;

            if (documentViewhepler.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                documentViewhepler.TotalPage = totalPage;
                documentViewhepler.Page = pageTransition(documentViewhepler.Direction, documentViewhepler.Page, totalPage);
                documentViewhepler.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, documentViewhepler.Page);
                documentViewhepler.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, documentViewhepler.Page, documentViewhepler.FirstPage);
                int take = Constant.limit;
                int skip = (documentViewhepler.Page - 1) * take;
                documentViewhepler.LstDocument = lstDocument.OrderByDescending(d => d.entry_datetime).Skip(skip).Take(take).ToList();
            }
            ViewData["documentViewhepler"] = documentViewhepler;
            return documentViewhepler;
        }
 public ActionResult Index(DocumentViewhepler DocumentViewhepler)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_VANBAN, Session.getCurrentUser().username, TypeAudit.Addnew)
         && !SercurityServices.HasPermission((int)TypeModule.MODULE_VANBAN, Session.getCurrentUser().username, TypeAudit.Edit)
         && !SercurityServices.HasPermission((int)TypeModule.MODULE_VANBAN, Session.getCurrentUser().username, TypeAudit.Delete))
     {
         return Redirect("/admin/error/error403");
     }
     saveData(DocumentViewhepler);
     return View();
 }