Пример #1
0
        public async Task <IActionResult> CatBreeds(int page = 0)
        {
            var catBreedsPage = await _repository.GetAll_paged(PageSize, page);

            var viewModel = new CatBreedsViewModel
            {
                //Map Viewmodel and Model
                CatBreeds = _mapper.Map <IEnumerable <CatBreed>, IEnumerable <CatBreedViewModel> >(catBreedsPage.PageList),
                Page      = page,
                PageCount = catBreedsPage.PageCount
            };

            return(View(viewModel));
        }
Пример #2
0
        public async Task <IActionResult> Search(string searchString, int page = 0)
        {
            var catBreedsPage = new PagedResult <CatBreed>();

            if (!String.IsNullOrEmpty(searchString))
            {
                catBreedsPage = await _repository.GetList_searched(searchString, page, PageSize);
            }
            else
            {
                catBreedsPage = await _repository.GetAll_paged(page, PageSize);
            }

            var viewModel = new CatBreedsViewModel
            {
                //Map Viewmodel and Model
                CatBreeds = _mapper.Map <IEnumerable <CatBreed>, IEnumerable <CatBreedViewModel> >(catBreedsPage.PageList),
                Page      = page,
                PageCount = catBreedsPage.PageCount
            };

            return(View(viewModel));
        }