示例#1
0
        public IActionResult Index(AllDataSearchModel filter, string?burialId, int pageNum = 1)
        {
            var filterLogic = new FilterLogic(_context);

            var queryModel = filterLogic.GetMummies(filter);
            int pageSize   = 120;

            //pagination

            return(View(new AllDataViewModel
            {
                AllData = (queryModel
                           .Skip((pageNum - 1) * pageSize)
                           .Take(pageSize)
                           .ToList()),

                PageNumberingInfo = new PageNumberingInfo
                {
                    NumItemsPerPage = pageSize,
                    CurrentPage = pageNum,
                    TotalNumItems = (burialId == null ? queryModel.Count() :
                                     queryModel.Where(x => x.BurialId == burialId).Count())
                },

                UrlInfo = Request.QueryString.Value
            }));
        }
示例#2
0
        public IQueryable <AllData> GetMummies(AllDataSearchModel searchModel, int pageNum = 1, int pageSize = 10)
        {
            var result = _context.AllData.AsQueryable();

            if (searchModel != null)
            {
                if (!string.IsNullOrEmpty(searchModel.BurialLocation))
                {
                    result = result.Where(x => x.BurialId.Contains(searchModel.BurialLocation));
                }
                if (!string.IsNullOrEmpty(searchModel.BurialDirection))
                {
                    result = result.Where(x => x.BurialDirection.Contains(searchModel.BurialDirection));
                }
                if (!string.IsNullOrEmpty(searchModel.HairColor))
                {
                    result = result.Where(x => x.HairColorCode.Contains(searchModel.HairColor));
                }
                if (!string.IsNullOrEmpty(searchModel.YearFound))
                {
                    result = result.Where(x => x.YearFound.Contains(searchModel.YearFound));
                }
                if (!string.IsNullOrEmpty(searchModel.Gender))
                {
                    result = result.Where(x => x.GenderCode.Contains(searchModel.Gender));
                }
                if (!string.IsNullOrEmpty(searchModel.AgeGroup))
                {
                    result = result.Where(x => x.EstimateAgeSingle.Contains(searchModel.AgeGroup));
                }
            }

            return(result);
        }