コード例 #1
0
        public void OnGet(string sortOrder,
                          string currentFilterName,
                          string searchStringName,
                          string currentFilterCAS,
                          string searchStringCAS,
                          int?pageIndex)
        {
            CurrentSort = sortOrder;
            NameSort    = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            CASSort     = String.IsNullOrEmpty(sortOrder) ? "cas_desc" : "";

            if (searchStringName != null)
            {
                pageIndex = 1;
            }
            else
            {
                searchStringName = currentFilterName;

                if (searchStringCAS != null)
                {
                    pageIndex = 1;
                }
                else
                {
                    searchStringCAS = currentFilterCAS;
                }
            }

            CurrentFilterName = searchStringName;
            CurrentFilterCAS  = searchStringCAS;

            IQueryable <Entity> entity = from s in db.Entities
                                         where s.EntityType == 2
                                         select s;

            if (!String.IsNullOrEmpty(searchStringName) && !String.IsNullOrEmpty(searchStringCAS))
            {
                entity = entity.Where(s => s.EntityName.ToUpper().Contains(searchStringName.ToUpper()) &&
                                      s.OtherId.ToUpper().Contains(searchStringCAS.ToUpper()));
            }
            else if (!String.IsNullOrEmpty(searchStringName))
            {
                entity = entity.Where(s => s.EntityName.ToUpper().Contains(searchStringName.ToUpper()));
            }
            else if (!String.IsNullOrEmpty(searchStringCAS))
            {
                entity = entity.Where(s => s.OtherId.ToUpper().Contains(searchStringCAS.ToUpper()));
            }
            switch (sortOrder)
            {
            case "name_desc":
                entity = entity.OrderByDescending(s => s.EntityName);
                break;

            case "cas_desc":
                entity = entity.OrderByDescending(s => s.OtherId);
                break;

            default:
                entity = entity.OrderBy(s => s.OtherId);
                break;
            }

            int pageSize = 10;

            Entity = PaginatedList <Entity> .Create(entity.AsNoTracking(), pageIndex ?? 1, pageSize);
        }
コード例 #2
0
        public void OnGet(string sortOrder,
                          string currentFilterPhrase,
                          string searchStringPhrase,
                          string currentFilterCode,
                          string searchStringCode,
                          int?pageIndex)
        {
            CurrentSort = sortOrder;
            PhraseSort  = String.IsNullOrEmpty(sortOrder) ? "phrase_desc" : "";
            CodeSort    = String.IsNullOrEmpty(sortOrder) ? "code_desc" : "";

            if (searchStringPhrase != null)
            {
                pageIndex = 1;
            }
            else
            {
                searchStringPhrase = currentFilterPhrase;

                if (searchStringCode != null)
                {
                    pageIndex = 1;
                }
                else
                {
                    searchStringCode = currentFilterCode;
                }
            }

            CurrentFilterPhrase = searchStringPhrase;
            CurrentFilterCode   = searchStringCode;

            IQueryable <EuphracPhrase> phrase = from s in db.Phrases
                                                select s;

            if (!String.IsNullOrEmpty(searchStringPhrase) && !String.IsNullOrEmpty(searchStringCode))
            {
                phrase = phrase.Where(s => s.English.ToUpper().Contains(searchStringPhrase.ToUpper()) &&
                                      s.EuPhraCStructureCode.Contains(searchStringCode));
            }
            else if (!String.IsNullOrEmpty(searchStringPhrase))
            {
                phrase = phrase.Where(s => s.English.ToUpper().Contains(searchStringPhrase.ToUpper()));
            }
            else if (!String.IsNullOrEmpty(searchStringCode))
            {
                phrase = phrase.Where(s => s.EuPhraCStructureCode.Contains(searchStringCode));
            }
            switch (sortOrder)
            {
            case "phrase_desc":
                phrase = phrase.OrderByDescending(s => s.English);
                break;

            case "code_desc":
                phrase = phrase.OrderByDescending(s => s.EuPhraCStructureCode);
                break;

            default:
                phrase = phrase.OrderBy(s => s.EuPhraCStructureCode);
                break;
            }

            int pageSize = 10;

            Phrase = PaginatedList <EuphracPhrase> .Create(phrase.AsNoTracking(), pageIndex ?? 1, pageSize);
        }