示例#1
0
        public void Ready()
        {
            Password = "******";
            Format   = string.Format("{{0:{0}}}", "".PadLeft(Site.AccountNameLength, '0'));
            IEnumerable <IdNamePair> query = AccountTypeService.Query(new AccountTypeRequest {
                State = States.Normal
            })
                                             .ToList().Select(x => new IdNamePair {
                Key = x.AccountTypeId, Name = x.DisplayName
            });

            AccountType.Bind(query);
            AccountType.Callback = "/AccountType/GetAccountTypeById/{0}";
            AccountToken         = Site.AccountToken;
            var         q     = DistributorService.Query();
            UserRequest user  = new UserRequest();
            var         users = MembershipService.QueryUsers <DistributorUser>(user).ToList();

            var list          = (from x in (q.Where(x => users.Any(u => u.UserId == x.UserId)).ToList())select new ListDistributor(x)
            {
                Owner = users.First(u => u.UserId == x.UserId)
            }).ToList();
            int distributorId = 0;
            var currentUser   = this.SecurityHelper.GetCurrentUser();

            if (currentUser is AdminUserModel)
            {
                var qq = (from x in list where x.InnerObject.ParentId == distributorId select new IdNamePair {
                    Key = x.DistributorId, Name = x.DisplayName
                }).ToList();
                qq.Insert(0, new IdNamePair {
                    Key = Ecard.Models.Distributor.Default.DistributorId, Name = Ecard.Models.Distributor.Default.FormatedName
                });
                Distributor.Bind(qq, false);
            }
            else if (currentUser is DistributorUserModel)
            {
                distributorId = ((DistributorUserModel)currentUser).DistributorId;
                var totalId = DistributorService.Query().Select(x => x.DistributorId).ToList();
                var ids     = GetChildrenDistributorId(distributorId, totalId);
                //ids.Add(distributorId);
                var qq = (from x in list where ids.Contains(x.DistributorId) select new IdNamePair {
                    Key = x.DistributorId, Name = x.DisplayName
                }).ToList();
                qq.Insert(0, new IdNamePair {
                    Key = Ecard.Models.Distributor.Default.DistributorId, Name = Ecard.Models.Distributor.Default.FormatedName
                });
                Distributor.Bind(qq, false);
            }
            //shop不要了这里也 可以不要了
            var qshop = (from x in ShopService.Query(new ShopRequest()
            {
                State = ShopStates.Normal, IsBuildIn = false
            })
                         select new IdNamePair {
                Key = x.ShopId, Name = x.FormatedName
            }).ToList();

            //qshop.Insert(0, new IdNamePair { Key = Ecard.Models.Shop.Default.ShopId, Name = Ecard.Models.Shop.Default.FormatedName });
            Shop.Bind(qshop, true, "全部");
            //var q = DistributorService.Query();
            //UserRequest user=new UserRequest();
            //user.Discriminator="DistributorUser";
            //var users = MembershipService.QueryUsers<DistributorUser>(new UserRequest()).ToList();

            // var list = (from x in (q.Where(x => users.Any(u => u.UserId == x.UserId)).ToList()) select new ListDistributor(x) { Owner=users.First(u=>u.UserId==x.UserId)}).ToList();
            //var qq = (from x in list select new IdNamePair { Key = x.DistributorId, Name = x.DisplayName }).ToList();
            //qq.Insert(0, new IdNamePair { Key = Ecard.Models.Distributor.Default.DistributorId, Name = Ecard.Models.Distributor.Default.FormatedName });
            // Distributor.Bind(qq, true);
            //var q = (from x in DistributorService.Query()users, x => new ListDistributor(x) { Owner = users.First(u => u.UserId == x.UserId
            //         select new IdNamePair { Key = x.DistributorId, Name = x. }).ToList();
            //q.Insert(0, new IdNamePair { Key = Ecard.Models.Shop.Default.ShopId, Name = Ecard.Models.Shop.Default.FormatedName });
            //Shop.Bind(q, true, "默认");Distributors.ListDistributor
        }