public ActionResult ShopPermission(OneKeySearchModel searchModel) { //IUsersService usersService = ServiceFactory.Create<IUsersService>(); Expression <Func <Shops, Boolean> > lbdWhere = null; if (searchModel.SearchStr != null) { searchModel.SearchStr = searchModel.SearchStr.Trim(); if (!string.IsNullOrWhiteSpace(searchModel.SearchStr)) { lbdWhere = t => t.ShopName.Contains(searchModel.SearchStr); } } IShopsService shopsService = ServiceFactory.Create <IShopsService>(); var shops = shopsService.GetEntitiesByPage(searchModel.PageIndex, 10, lbdWhere, false, t => t.ID); //转换数据模型 var listData = shops.Models.Select(t => new ShopPermissionListModel { ID = t.ID, ShopName = t.ShopName, RealName = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).RealName,// t.Users.RealName, Phone = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).Phone }); var listShop = new PageModel <ShopPermissionListModel> { Models = listData.ToList(), pagingInfo = shops.pagingInfo }; ViewBag.SearchModel = searchModel; return(View(listShop)); }
public JsonResult GetShopsJson(int pageindex, int pagesize, string cols, string qtext) { IShopsService shopsService = ServiceFactory.Create <IShopsService>(); int total = 0; //pageindex默认从0开始,也就是第一页是0,所以pageindex + 1 var data = shopsService.GetEntitiesByPage(pageindex + 1, pagesize, out total, t => t.Disabled != true && t.ShopName.Contains(qtext), false, t => t.ID).ToList().Select(t => new //(t => t.DefaultStoreID == CurrentInfo.CurrentUser.DefaultStoreID) { ID = t.ID, ShopName = t.ShopName, DueDate = t.DueDate.ToString("yyyy-MM-dd") }).ToList(); //返回值记得加total前端要用 return(Json(new { total = total, rows = data }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetShopsPage(int pageSize, int pageNumber, string shopName, string MerchantID) { //SearchModel<ShopsParams> searchModel = new SearchModel<ShopsParams> //{ // PageIndex = pageNumber, // PageSize = pageSize, // Model = new ShopsParams() { ShopName = shopName } //}; var expr = BuildSearchCriteria(shopName, MerchantID); int total; //WhereHelper<Shops> where = new WhereHelper<Shops>(); //if (!string.IsNullOrEmpty(shopName)) //{ // where.Contains("ShopName", shopName); //} IShopsService shopsService = ServiceFactory.Create <IShopsService>(); var data = shopsService.GetEntitiesByPage(pageNumber, pageSize, out total, expr, false, t => t.ID).ToList().Select(t => new { ID = t.ID, MerchantID = "61" + t.ID.ToString().PadLeft(4, '0'), ShopName = t.ShopName, UserID = t.AdminUserID, //ThisUser = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID), UserName = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).UserName, TotalMoney = t.TotalMoney, Phone = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).Phone, DueDate = t.DueDate.ToString("yyyy-MM-dd"), CreateUser = "******", CreateTime = t.CreateTime.ToString("yyyy-MM-dd"), NoticeOpenID = t.NoticeOpenID, Disabled = t.Disabled == true, ShopType = t.ShopType, ShopVersionName = t.ShopVersion.Name, SalespersonName = "销售员", Deposit = t.Deposit, FinalPayment = t.FinalPayment, RegionText = t.Province + "." + t.City + "." + t.County }).ToList(); return(Json(new { total = total, rows = data }, JsonRequestBehavior.AllowGet)); }