public ActionResult ListProducts(ProductListAdminSearchCriteria searchCriteria) { ProductListAdminQueryBuilder queryBuilder = new ProductListAdminQueryBuilder(searchCriteria); var categories = daoTemplate.FindAll<Category>(); var result = queryBuilder.Execute(daoTemplate.Session); return View(new ProductListViewModel{SearchResults = result, Categories = categories}); }
public ProductListAdminQueryBuilder(ProductListAdminSearchCriteria criteria) : base(criteria) { if (criteria.CategoryId.HasValue) { _category = _daoTemplate.FindByID <Category>(criteria.CategoryId); } }
public ProductListAdminSearchCriteria WithCategoryId(int categoryId) { ProductListAdminSearchCriteria another = this.Clone <ProductListAdminSearchCriteria>(); another.CategoryId = categoryId; // need to reset page index another.PageIndex = 1; return(another); }