コード例 #1
0
        public JsonNetResult QueryMyMerchant(WebQueryFilter filter)
        {
            if (this.Auth.GetAuthenticatedUser() == null)
            {
                return new JsonNetResult()
                       {
                           Data = new { }
                       }
            }
            ;

            filter.Columns.Add(new QueryColumnFilter()
            {
                Data       = "EnjoyUser.Id",
                Searchable = true,
                DbType     = System.Data.DbType.Int64,
                Search     = new SearchColumnFilter()
                {
                    Regex = false, Value = this.Auth.GetAuthenticatedUser().Id
                }
            });

            var condition = new PagingCondition(filter.Start, filter.Length);
            var viewModel = this.Merchant.QueryMerchants(filter, condition);

            return(new JsonNetResult()
            {
                Data = viewModel
            });
        }
コード例 #2
0
        public PagingData <M> Query(
            WebQueryFilter filter,
            PagingCondition condition,
            Action <ICriteria> builder,
            Func <R, M> convert)
        {
            var session  = this.OS.TransactionManager.GetSession();
            var criteria = session.CreateCriteria(typeof(R));

            condition = condition ?? new PagingCondition(0, int.MaxValue);
            if (builder != null)
            {
                builder(criteria);
            }
            if (filter != null)
            {
                criteria.WithQueryFilter(filter).WithQueryOrder(filter);
            }
            criteria.ClearOrders();
            var pageCriteria = CriteriaTransformer.Clone(criteria);
            var page         = (condition.Skip / condition.Take) - 1;

            return(new PagingData <M>()
            {
                TotalCount = Convert.ToInt32(criteria.SetProjection(Projections.RowCount()).UniqueResult()),
                Items = pageCriteria.SetFirstResult(condition.Skip)
                        .SetMaxResults(condition.Take)
                        .List <R>()
                        .Select(o => convert(o))
                        .ToList(),
                Paging = new Paging(page, condition.Take)
            });
        }
コード例 #3
0
 public PagingData <ShopModel> QueryMyShops(long merchantid, PagingCondition condition)
 {
     return(base.Query(condition, builder =>
     {
         builder.Add(Expression.Eq("Merchant.Id", merchantid));
     }, (record) => new ShopModel(record)));
 }
コード例 #4
0
 public PagingData <ShopModel> QueryShops(PagingCondition condition)
 {
     return(base.Query(condition, builder =>
     {
     },
                       record => new ShopModel(record)));
 }
コード例 #5
0
        public void GetPagingDtoData <TDto>(PagingCondition pagingCondition, out List <TDto> recordData, out long recordCount, IQueryCondition <TEntity> queryCondition = null)
        {
            var query = GetQueryableEntityByConditon(pagingCondition, queryCondition);

            recordCount = query.Count();
            recordData  = query.Skip(pagingCondition.Skip).Take(pagingCondition.PageSize).Project().To <TDto>().ToList();
        }
コード例 #6
0
        public void TestGetAccountPagingData()
        {
            var conditionBuilder = ConditionBuilder <Account> .Create();

            conditionBuilder.OrderBy(x => x.Sex).ThenBy(x => x.CreateTime);
            var pagingCondition = new PagingCondition(0, 15);

            Account.GetPagingDtoData <AccountDto>(pagingCondition, conditionBuilder);
        }
コード例 #7
0
ファイル: AggregateRootBase.cs プロジェクト: 51b/EasyAccess
        public static PagingData <TEntity> GetPagingEdmData(
            PagingCondition pagingCondition,
            IQueryCondition <TEntity> queryCondition = null)
        {
            long           recordCount;
            List <TEntity> recordData;

            Repository.GetPagingEdmData(pagingCondition, out recordData, out recordCount, queryCondition);
            return(new PagingData <TEntity>(recordCount, pagingCondition, recordData));
        }
コード例 #8
0
 public PagingData <MerchantModel> QueryMerchants(
     WebQueryFilter filter,
     PagingCondition condition)
 {
     return(this.Query(condition, (builder) =>
     {
         builder.WithQueryFilter(filter);
         //builder.WithQueryOrder(filter);
     },
                       (record) => Convert(record)));
 }
コード例 #9
0
        public PagingData <MerchantModel> QueryMyMerchants(long userid, int page)
        {
            var apply     = this.WeChat.GetApplyProtocol();
            var condition = PagingCondition.GenerateByPageAndSize(page, Constants.DefaultPageSize);

            return(this.Query(condition, (builder) =>
            {
                builder.Add(Expression.Eq("EnjoyUser.Id", userid));
            },
                              record => Convert(record)));
        }
コード例 #10
0
ファイル: AggregateRootBase.cs プロジェクト: 51b/EasyAccess
        public static PagingData <TDto> GetPagingDtoData <TDto>(
            PagingCondition pagingCondition,
            IQueryCondition <TEntity> queryCondition = null)
            where TDto : class
        {
            long        recordCount;
            List <TDto> recordData;

            Repository.GetPagingDtoData(pagingCondition, out recordData, out recordCount, queryCondition);
            return(new PagingData <TDto>(recordCount, pagingCondition, recordData));
        }
コード例 #11
0
 public PagingData <CardCounponModel> QueryCardCoupon(PagingCondition condition, CardTypes type)
 {
     return(this.Query(condition, (builder) =>
     {
         if (type != CardTypes.None)
         {
             builder.Add(Expression.Eq("CardType", type));
         }
     },
                       (record) =>
     {
         return new CardCounponModel(record);
     }));
 }
コード例 #12
0
        public JsonNetResult QueryMyShops(WebQueryFilter filter)
        {
            if (this.Auth.GetAuthenticatedUser() == null)
            {
                return new JsonNetResult()
                       {
                           Data = new { }
                       }
            }
            ;
            var merchant = this.Merchant.GetDefaultMerchant();

            if (filter.Fixation != null)
            {
                foreach (var key in filter.Fixation.Keys)
                {
                    var column = new QueryColumnFilter()
                    {
                        Data       = key,
                        Searchable = true,
                        Search     = new SearchColumnFilter()
                        {
                            Regex = false, Value = filter.Fixation[key]
                        }
                    };
                    if (key.Equals("Merchant.Id", StringComparison.OrdinalIgnoreCase))
                    {
                        column.DbType = System.Data.DbType.Int64;
                    }
                    filter.Columns.Add(column);
                }
            }

            var condition = new PagingCondition(filter.Start, filter.Length);
            var model     = client.Convert(this.Shop.QueryShops(filter, condition));

            model.Draw = filter.Draw;
            return(new JsonNetResult()
            {
                Data = model
            });
        }
コード例 #13
0
        public List <ApiModel::Banner> QueryMerchants(ApiModel::PagingX paging)
        {
            var condition = PagingCondition.GenerateByPageAndSize(paging.Page, paging.PageSize);

            return(this._merchantService.QueryMerchants(new WebQueryFilter()
            {
                Columns = new List <QueryColumnFilter>()
                {
                    ////TODO 正式版本中需要取消下面这段代码的注释
                    //new QueryColumnFilter(){
                    //    Name ="Status",
                    //    Searchable = true,
                    //     DbType = System.Data.DbType.String,
                    //    Search = new SearchColumnFilter(){
                    //         Value = AuditStatus.APPROVED
                    //    },
                    //    Orderable = true,
                    //    Data = "Status"
                    //}
                },
                Order = new List <QueryOrderFilter>()
                {
                    new QueryOrderFilter()
                    {
                        ColumnName = "CreateTime",
                        Dir = Direction.Asc
                    }
                }
            }, condition)
                   .Items
                   .Select((ctx) =>
            {
                return new ApiModel::Banner()
                {
                    LinkName = ctx.BrandName,
                    LinkTo = string.Empty,
                    LogoUrl = ctx.LogoUrl,
                    LinkType = 9
                };
            }).ToList());
        }
コード例 #14
0
        private IQueryable <TEntity> GetQueryableEntityByConditon(
            PagingCondition pagingCondition,
            IQueryCondition <TEntity> queryCondition = null)
        {
            if (queryCondition != null)
            {
                var query = Entities.Where(queryCondition.Predicate);
                IOrderedQueryable <TEntity> orderCondition = null;
                if (queryCondition.OrderByConditions == null || queryCondition.OrderByConditions.Count == 0)
                {
                    orderCondition = query.OrderBy(x => x.Id);
                }
                else
                {
                    var i = 0;
                    foreach (var keySelector in queryCondition.OrderByConditions)
                    {
                        orderCondition = i == 0
                                             ? keySelector.Value.Direction == ListSortDirection.Ascending
                                                   ? Queryable.OrderBy(query, (dynamic)keySelector.Value.KeySelector)
                                                   : Queryable.OrderByDescending(query,
                                                                                 (dynamic)keySelector.Value.KeySelector)
                                             : keySelector.Value.Direction == ListSortDirection.Ascending
                                                   ? Queryable.ThenBy(orderCondition,
                                                                      (dynamic)keySelector.Value.KeySelector)
                                                   : Queryable.ThenByDescending(orderCondition,
                                                                                (dynamic)keySelector.Value.KeySelector);

                        i++;
                    }
                }
                query = orderCondition;
                return(query);
            }
            else
            {
                var query = Entities.Where(ConditionBuilder <TEntity> .Empty).OrderBy(x => x.Id);
                return(query);
            }
        }
コード例 #15
0
 public PagingData <ShopModel> QueryShops(WebQueryFilter filter, PagingCondition condition)
 {
     return(Query(filter, condition, null, r => new ShopModel(r)));
 }
コード例 #16
0
 public PagingData <CardCounponModel> QueryCardCoupon(WebQueryFilter filter, PagingCondition condition)
 {
     return(base.Query(filter, condition, null, record => new CardCounponModel(record)));
 }
コード例 #17
0
 public PagingData <M> Query(PagingCondition condition, Action <ICriteria> builder, Func <R, M> convert)
 {
     return(Query(null, condition, builder, convert));
 }