示例#1
0
 public ViewResult SearchProduct(string search)
 {
     ProductsListViewModel model = new ProductsListViewModel
     {
         Products = repository.Products
         .Where(p => p.Description.Contains(search.ToString()))
     };
     return View(model);
 }
示例#2
0
 // GET: Product Details
 public ViewResult Details(string id)
 {
     ProductsListViewModel model = new ProductsListViewModel
     {
         Products = repository.Products
         .Where(p => p.ProductID == Convert.ToInt32(id))
     };
     return View(model);
 }
示例#3
0
 // GET: Product
 public ViewResult List(string category, int page = 1)
 {
     ProductsListViewModel model = new ProductsListViewModel
     {
         Products = repository.Products
         .Where(p => category == null || p.Category == category)
         .OrderBy(p => p.ProductID)
         .Skip((page - 1) * PageSize)
         .Take(PageSize),
         PagingInfo = new PagingInfo
         {
             CurrentPage = page,
             ItemsPerPage = PageSize,
             TotalItems = category == null ? repository.Products.Count() : repository.Products.Where(e => e.Category == category).Count()
         },
         CurrentCategory = category
     };
     return View(model);
 }