Пример #1
0
		// 搜索商品
		public List<Product> SearchProduct(ProductSearchInfo info)
		{
			var query = from product in WebSiteDB.MyNorthwind.Products.AsQueryable()
						select product;

			if( info.CategoryId > 0 )
				query = query.Where(p => p.CategoryID == info.CategoryId);

			if( string.IsNullOrEmpty(info.SearchWord) == false )
				query = query.Where(p => p.ProductName.Contains(info.SearchWord));


			return query.OrderBy(x => x.ProductName).GetPagingList<Product>(info);
		}
Пример #2
0
		public object ShowProductPicker(int? categoryId, string searchWord, int? page)
		{
			ProductSearchInfo info = new ProductSearchInfo();
			info.CategoryId = categoryId.HasValue ? categoryId.Value : 0;
			info.SearchWord = searchWord ?? string.Empty;
			info.PageIndex = page.HasValue ? page.Value - 1 : 0;
			info.PageSize = AppHelper.DefaultPageSize;


			ProductPickerModel data = new ProductPickerModel();
			data.SearchInfo = info;
			data.List = BllFactory.GetProductBLL().SearchProduct(info);
			data.CategoryList = BllFactory.GetCategoryBLL().GetList();

			return new PageResult("/Pages/Style1/Controls/ProductPicker.cshtml", data);
		}
		public object LoadModel(int? categoryId, int? page)
		{
			string papeUrl = this.GetTargetPageUrl("Products.aspx");

			if( this.IsStyle2 )
				// Style2 风格下,页面不需要绑定数据。数据由JS通过AJAX方式获取
				return new PageResult(papeUrl, null);


			ProductsPageModel result = new ProductsPageModel();
			result.Categories = BllFactory.GetCategoryBLL().GetList();

			if( result.Categories.Count == 0 ) {
				return new RedirectResult("/Pages/Categories.aspx");
			}

			// 获取当前用户选择的商品分类ID
			ProductSearchInfo info = new ProductSearchInfo();
			info.CategoryId = categoryId.HasValue ? categoryId.Value : 0;
			if( info.CategoryId == 0 )
				info.CategoryId = result.Categories[0].CategoryID;
			info.PageIndex = page.HasValue ? page.Value - 1 : 0;
			info.PageSize = AppHelper.DefaultPageSize;


			result.ProductInfo = new ProductInfoModel(
						result.Categories, new Product { CategoryID = info.CategoryId });
			result.PagingInfo = info;
			result.CurrentCategoryId = info.CategoryId;
			result.RequestUrlEncodeRawUrl = HttpUtility.UrlEncode(this.HttpContext.Request.RawUrl);


			// 加载商品列表
			result.Products = BllFactory.GetProductBLL().SearchProduct(info);

			return new PageResult(papeUrl, result);
		}
Пример #4
0
		public List<Product> SearchProduct(ProductSearchInfo info)
		{
			return DbHelper.FillListPaged<Product>("SearchProduct", info);
		}
Пример #5
0
		public object List(ProductSearchInfo pagingInfo)
		{
			pagingInfo.CheckPagingInfoState();

			List<Product> List = BllFactory.GetProductBLL().SearchProduct(pagingInfo);
			var result = new GridResult<Product>(List, pagingInfo.TotalRecords);
			return new JsonResult(result);
		}