コード例 #1
0
ファイル: ProductBLL.cs プロジェクト: rockhe168/PracticeCode
		// 搜索商品
		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
ファイル: AjaxProduct.cs プロジェクト: rockhe168/PracticeCode
		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 UcResult("/Controls/Style1/ProductPicker.ascx", data);
		}
コード例 #3
0
		public static object LoadModel(int? categoryId, int? page)
		{
			string papeUrl = StyleHelper.GetTargetPageUrl("Products.aspx");

			if( StyleHelper.PageStyle == StyleHelper.StyleArray[1] )
				// 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.Products = BllFactory.GetProductBLL().SearchProduct(info);

			return new PageResult(papeUrl, result);
		}
コード例 #4
0
ファイル: AjaxProduct.cs プロジェクト: rockhe168/PracticeCode
		public object List(ProductSearchInfo pagingInfo)
		{
			pagingInfo.CheckPagingInfoState();

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