public ActionResult List(ShopCartItemServiceClient cart, string category, string subcategory, int page = 1, string name = null) { ProductsListView productsList = new ProductsListView { CurrentCategory = category, SubCategory = subcategory, ProductName = name, PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = name == null?dataRepository.GetList().Where(x => x.SubCategory == subcategory).Count() : dataRepository.GetList().Where(x => x.Name.Contains(name)).Count() }, ProductCatalog = subcategory != null?dataRepository.GetList() .Where(x => x.SubCategory == subcategory || x.SubCategory == null) .OrderBy(x => x.ID) .Skip((page - 1) * PageSize) .Take(PageSize) : dataRepository.GetList().Where(x => x.Name.Contains(name)) .OrderBy(x => x.ID).Skip((page - 1) * PageSize).Take(PageSize), Cart = cart }; productsList.CountActualProduct(); return(View(productsList)); }