Example #1
0
        public ActionResult Index(string q)
        {
            var model = new ProductsIndexViewModel { Products = _session.Query<Product>() };

            return View(model);
        }
Example #2
0
 private ProductsIndexViewModel prepareProductSearchViewModel(int page = 1, int pageSize = DEFAULT_PAGE_SIZE,
     string keywords = null, int? categoryId = null, bool? featured = null, bool? visible = null,
     string orderColumn = null, bool orderAsc = true)
 {
     if (keywords == "null") keywords = null;
     var orderExpr = productFinder.CreateOrderExpr(orderColumn).Expand();
     var products = productFinder.Find(categoryId, false, keywords, featured, visible,
         orderExpr: orderExpr, orderAsc: orderAsc);
     var model = new ProductsIndexViewModel
                 {
                     Page = page,
                     PageSize = pageSize,
                     TotalItems = products.Count(),
                     OrderColumn = orderColumn,
                     OrderAsc = orderAsc,
                     Keywords = keywords,
                 };
     model.TotalPages = ((model.TotalItems - 1)/pageSize) + 1;
     if (model.TotalPages < model.Page)
         model.Page = model.TotalPages;
     model.Products = Mapper.Map<List<ProductSearchViewModel>>(products.GetPage(model.Page, model.PageSize));
     return model;
 }