public JsonResult List(int page, int rows, string levelNameCN, string levelNameEN) //string companyName, { ProductLevelQuery productLevelQuery = new ProductLevelQuery(); if (!string.IsNullOrWhiteSpace(levelNameCN)) { productLevelQuery.ProductLevelCN = levelNameCN; } if (!string.IsNullOrWhiteSpace(levelNameEN)) { productLevelQuery.ProductLevelEN = levelNameEN; } productLevelQuery.PageSize = rows; productLevelQuery.PageNo = page; PageModel <ProductLevel> productLevels = ServiceHelper.Create <IProductLevelService>().GetProductLevels(productLevelQuery); IProductLevelService levelService = ServiceHelper.Create <IProductLevelService>(); IEnumerable <ProductLevelModel> array = from item in productLevels.Models.ToArray() select new ProductLevelModel() { Id = item.Id, LevelNameCN = item.LevelNameCN, LevelNameEN = item.LevelNameEN }; DataGridModel <ProductLevelModel> dataGridModel = new DataGridModel <ProductLevelModel>() { rows = array, total = productLevels.Total }; return(Json(dataGridModel)); }
public PageModel <ProductLevel> GetProductLevels(ProductLevelQuery ProductLevelQueryModel) { // IQueryable<FieldCertification> CertificationShop = context.FieldCertification.AsQueryable<FieldCertification>(); IQueryable <ProductLevel> ProductLevels = from item in base.context.ProductLevel select item; long Id = ProductLevelQueryModel.Id; if ((Id > 0)) { ProductLevels = from item in ProductLevels where item.Id == ProductLevelQueryModel.Id select item; } if (!string.IsNullOrWhiteSpace(ProductLevelQueryModel.ProductLevelCN)) { ProductLevels = from d in ProductLevels where d.LevelNameCN.Contains(ProductLevelQueryModel.ProductLevelCN) select d; } if (!string.IsNullOrWhiteSpace(ProductLevelQueryModel.ProductLevelEN)) { ProductLevels = from d in ProductLevels where d.LevelNameEN.Contains(ProductLevelQueryModel.ProductLevelEN) select d; } Func <IQueryable <ProductLevel>, IOrderedQueryable <ProductLevel> > func = null; func = (IQueryable <ProductLevel> d) => from o in d orderby o.Id descending select o; int num = ProductLevels.Count(); ProductLevels = ProductLevels.GetPage(out num, ProductLevelQueryModel.PageNo, ProductLevelQueryModel.PageSize, func); return(new PageModel <ProductLevel>() { Models = ProductLevels, Total = num }); }