Exemple #1
0
        public async Task <Tuple <int, List <SlideShowDTO> > > LoadAsyncCount(
            int skip = -1,
            int take = -1,
            SlideShowSearchViewModel model = null)
        {
            var query = Entities.ProjectTo <SlideShowDTO>();

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



            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 <SlideShowDTO> >(Count, await query.ToListAsync()));
        }
        public async Task <IActionResult> Index(SlideShowSearchViewModel searchModel)
        {
            var model = await _slideShowRepository.LoadAsyncCount(
                this.CurrentPage,
                this.PageSize,
                searchModel);

            this.TotalNumber = model.Item1;

            ViewBag.SearchModel = searchModel;

            return(View(model.Item2));
        }