Пример #1
0
        public async Task <IActionResult> Index(FeatureSearchViewModel searchModel)
        {
            var model = await _featureRepository.LoadAsyncCount(
                this.CurrentPage,
                this.PageSize,
                searchModel);

            this.TotalNumber = model.Item1;

            ViewBag.SearchModel = searchModel;

            return(View(model.Item2));
        }
Пример #2
0
        public async Task OnGetAsync(string pageNo, string featureName, bool deleted, FeatureTypeEnum?type, string dateFrom, string dateTo, string creatorId, string status)
        {
            SearchInput = new FeatureSearchViewModel
            {
                PageNo = pageNo.FixPageNumber(),
                Name   = featureName,
                IncludeDeletedItems = deleted,
                Type             = type,
                CreatorId        = creatorId,
                CreationDateFrom = dateFrom,
                CreationDateTo   = dateTo
            };

            Status = !string.IsNullOrEmpty(status)
                ? status
                : null;
            List = await _featureService.FeatureListAsync(SearchInput, false);
        }
        public async Task <Tuple <int, List <FeatureFullDetailDTO> > > LoadAsyncCount(
            int skip = -1,
            int take = -1,
            FeatureSearchViewModel model = null)
        {
            var query = Entities.ProjectTo <FeatureFullDetailDTO>();

            if (!string.IsNullOrEmpty(model.Title))
            {
                query = query.Where(x => x.Title.Contains(model.Title));
            }


            if (model.FeatureType != null)
            {
                query = query.Where(x => x.FeatureType == model.FeatureType);
            }


            int Count = query.Count();

            query = query.OrderByDescending(x => x.Id);


            if (skip != -1)
            {
                query = query.Skip((skip - 1) * take);
            }

            if (take != -1)
            {
                query = query.Take(take);
            }



            return(new Tuple <int, List <FeatureFullDetailDTO> >(Count, await query.ToListAsync()));
        }