コード例 #1
0
ファイル: ListShopDealLogs.cs プロジェクト: a864610877/src
        public void Query()
        {
            var request = new ShopDealLogRequest();

            if (State != ShopDealLogStates.All)
            {
                request.State = State;
            }
            request.SubmitDateMin = Data.Start;
            request.SubmitDateMax = Data.GetEnd();
            request.AccountName   = AccountName;
            if (Shop != Globals.All)
            {
                request.ShopId = Shop;
            }
            request.SerialNo    = SerialNo;
            request.IsLiquidate = IsLiquidate;
            var user = SecurityHelper.GetCurrentUser().CurrentUser as ShopUser;

            if (user != null)
            {
                request.ShopId = user.ShopId;
            }
            if (AccountShop != Globals.All)
            {
                request.AccountShopId = AccountShop;
            }
            var query = ShopDealLogService.Query(request);

            this.List = query.ToList(this, x => new ListShopDealLog(x));

            var shopIds = List.Select(x => x.InnerObject.ShopId).Distinct();
            var shops   = ShopService.Query(new ShopRequest()
            {
                ShopIds = shopIds.ToArray()
            }).ToList();

            foreach (var log in List)
            {
                var shop = shops.FirstOrDefault(x => x.ShopId == log.InnerObject.ShopId);
                if (shop != null)
                {
                    log.TempShop = shop;
                }
            }

            var dealLogIds = List.Select(x => x.InnerObject.Addin).Distinct();

            var dealLogs = DealLogService.GetByIds(dealLogIds.ToArray()).ToList();

            foreach (var log in List)
            {
                var shop = dealLogs.FirstOrDefault(x => x.DealLogId == log.InnerObject.Addin);
                if (shop != null)
                {
                    log.DealLog = shop;
                }
            }


            //
            var q = (from x in ShopService.Query(new ShopRequest()
            {
                IsBuildIn = false, State = ShopStates.Normal
            })
                     select new IdNamePair {
                Key = x.ShopId, Name = x.FormatedName
            }).ToList();

            q.Insert(0, new IdNamePair {
                Key = Ecard.Models.Shop.Default.ShopId, Name = Ecard.Models.Shop.Default.FormatedName
            });
            this.AccountShop.Bind(q, true);
        }