public ActionResult List(UserViewModel model) { model = model ?? new UserViewModel(); model.UserSearch = model.UserSearch ?? new SearchUserCriteria(); var search = new SearchUserCriteria() { UserId = model.UserSearch.UserId, USER_CODE = model.UserSearch.USER_CODE, RoleID = model.UserSearch.RoleID, UserName = model.UserSearch.UserName, //SuspendFlag = model.UserSearch.Suspend ? "Y" : "N" Suspend = model.UserSearch.Suspend }; List<Comparison<UserModel>> compList = new List<Comparison<UserModel>>(); compList.Add((x, y) => x.UserCode.CompareTo(y.UserCode)); //commented by jason in 20121219 for TSYF02010#06.doc //compList.Add((x, y) => x.UserName.CompareTo(y.UserName)); //end commented by jason in 20121219 for TSYF02010#06.doc compList.Add((x, y) => x.UserType.CompareTo(y.UserType)); compList.Add((x, y) => x.CreationDate.CompareTo(y.CreationDate)); compList.Add((x, y) => x.ShopCount.CompareTo(y.ShopCount)); compList.Add((x, y) => x.SystemScope.CompareTo(y.SystemScope)); //commented by jason in 20121219 for TSYF02010#06.doc //compList.Add((x, y) => x.SuspendFlag.CompareTo(y.SuspendFlag)); //compList.Add((x, y) => (x.SuspendDate.HasValue ? x.SuspendDate.Value.Format() : "").CompareTo(y.SuspendDate.HasValue ? y.SuspendDate.Value.Format() : "")); //compList.Add((x, y) => x.FrozenFlag.CompareTo(y.FrozenFlag)); //compList.Add((x, y) => (x.FrozenDate.HasValue ? x.FrozenDate.Value.Format() : "").CompareTo(y.FrozenDate.HasValue ? y.FrozenDate.Value.Format() : "")); //end commented by jason in 20121219 for TSYF02010#06.doc //model.UserList = BusinessPortal.Search<UserModel>(search); model.UserList = SessionCache.Instance.GetOrSetCache<BusinessList<UserModel>>("userSearch", () => BusinessPortal.Search<UserModel>(search), !this.IsSortingOrPageing()); PagerHelper.SetSortParamsToViewData(ViewData, new PageParams() { SortField = 0, sortDirection = SortDirectionEnum.Asc }); return ViewList(model, (pageparams) => { model.RoleForDropDownList = BusinessPortal.Search<Role>(new SearchRoleForDDLCriteria()); model.UserForDropDownList = BusinessPortal.Search<UserModel>(new SearchUserForDDLCriteria()); int recordCount; model.UserList = model.UserList.Page(pageparams, out recordCount, compList); return recordCount; }); }
public ActionResult UserRole(long? userId, UserViewModel model) { model = model ?? new UserViewModel(); model.ShopRoleSearch = model.ShopRoleSearch ?? new UserRoleShopInUserCriteria(); //string shop = Request["ShopRoleSearch.ShopCode"]; var userSearch = new SearchUserCriteria() { UserId = userId.HasValue ? userId.Value : -1 }; string shopCode = string.Empty; //如果当前用户是公司用户,ShopCode=当前店,否则=选择的店 if(App.Framework.Security.User.Current.UserType == CSC.Business.UserTypes.NS.ToString()){ shopCode = App.Framework.Security.User.Current.ShopCode; } else{ //第一次进入此页面时,model.ShopRoleSearch.ShopCode == null。默认选择第DDL里面的第一个shop /*if (model.ShopRoleSearch.ShopCode == null) { BusinessList<Shop> shopList = BusinessPortal.Search<Shop>(new SearchShopByUserIDInUserCriteria() { UserId = userId.HasValue ? userId.Value : -1 }); if (shopList != null && shopList.Count > 0) { shopCode = shopList[0].Code; } } else {*/ shopCode = model.ShopRoleSearch.ShopCode; //} } var search = new UserRoleShopInUserCriteria() { UserId = userId.Value, ShopCode = shopCode }; var userRoleShoplist = string.IsNullOrEmpty(search.ShopCode) ? new BusinessList<UserRole>() : BusinessPortal.Search<UserRole>(search); UserViewModel viewModel = new UserViewModel() { UserModel = BusinessPortal.Load<UserModel>(userSearch), //只加载登录用户权限范围店铺 ShopForDropDownList = BusinessPortal.Search<Shop>(new SearchShopByUserIDInUserCriteria() { UserId = userId.HasValue ? userId.Value : -1 }), UserRoleShopList = userRoleShoplist }; return View(viewModel); }
public ActionResult DoEdit(long? userId, Func<object, ActionResult> View) { var userSearch = new SearchUserCriteria() { UserId = userId.HasValue ? userId.Value : -1 }; var userShopCriteria = new UserShopInUserCriteria() { UserId = userId.HasValue ? userId.Value : -1 }; UserViewModel viewModel = new UserViewModel() { UserModel = BusinessPortal.Load<UserModel>(userSearch), UserShopList = BusinessPortal.Search<UserShop>(userShopCriteria) }; return View(viewModel); }