コード例 #1
0
        public JsonResult List(int page, int rows, string collName)
        {
            ICollocationService collocationService = ServiceHelper.Create <ICollocationService>();
            CollocationQuery    collocationQuery   = new CollocationQuery()
            {
                Title    = collName,
                ShopId   = new long?(base.CurrentSellerManager.ShopId),
                PageSize = rows,
                PageNo   = page
            };
            PageModel <CollocationInfo> collocationList = collocationService.GetCollocationList(collocationQuery);
            var list =
                from item in collocationList.Models.ToList()
                select new { Id = item.Id, StartTime = item.StartTime.ToString("yyyy/MM/dd"), EndTime = item.EndTime.ToString("yyyy/MM/dd"), Title = item.Title, ShopName = item.ShopName, ProductId = item.ProductId, Status = item.Status };

            return(Json(new { rows = list, total = collocationList.Total }));
        }
コード例 #2
0
        public ObsoletePageModel <CollocationInfo> GetCollocationList(CollocationQuery query)
        {
            int total = 0;
            var coll  = Context.CollocationInfo.Join(Context.ShopInfo, a => a.ShopId, b => b.Id, (a, b) => new CollocationModel
            {
                Id         = a.Id,
                CreateTime = a.CreateTime.Value,
                StartTime  = a.StartTime,
                EndTime    = a.EndTime,
                Title      = a.Title,
                ShortDesc  = a.ShortDesc,
                ShopName   = b.ShopName,
                ShopId     = a.ShopId,
                ProductId  = 0,
            });

            coll = coll.Join(Context.CollocationPoruductInfo.Where(t => t.IsMain == true), a => a.Id, b => b.ColloId, (a, b) => new CollocationModel
            {
                Id         = a.Id,
                CreateTime = a.CreateTime.Value,
                StartTime  = a.StartTime,
                EndTime    = a.EndTime,
                Title      = a.Title,
                ShortDesc  = a.ShortDesc,
                ShopName   = a.ShopName,
                ShopId     = a.ShopId,
                ProductId  = b.ProductId
            }
                             );
            if (!string.IsNullOrEmpty(query.Title))
            {
                coll = coll.Where(d => d.Title.Contains(query.Title));
            }
            if (query.ShopId.HasValue)
            {
                coll = coll.Where(d => d.ShopId == query.ShopId.Value);
            }
            coll = coll.GetPage(out total, query.PageNo, query.PageSize, d => d.OrderByDescending(item => item.CreateTime));
            ObsoletePageModel <CollocationInfo> pageModel = new ObsoletePageModel <CollocationInfo>()
            {
                Models = coll, Total = total
            };

            return(pageModel);
        }
コード例 #3
0
        public QueryPageModel <CollocationInfo> GetCollocationList(CollocationQuery query)
        {
            var coll = DbFactory.Default
                       .Get <CollocationInfo>()
                       .InnerJoin <ShopInfo>((ci, si) => si.Id == ci.ShopId)
                       .InnerJoin <CollocationPoruductInfo>((ci, cpi) => ci.Id == cpi.ColloId && cpi.IsMain == true)
                       .Select()
                       .Select <ShopInfo>(n => n.ShopName)
                       .Select <CollocationPoruductInfo>(n => n.ProductId);

            if (!string.IsNullOrEmpty(query.Title))
            {
                coll.Where(d => d.Title.Contains(query.Title));
            }
            if (query.ShopId.HasValue)
            {
                coll.Where(d => d.ShopId == query.ShopId.Value);
            }
            if (query.Status > 0)
            {
                switch (query.Status)
                {
                case 1:
                    coll.Where(d => d.StartTime <= DateTime.Now && d.EndTime >= DateTime.Now); break;    //进行中

                case 2:
                    coll.Where(d => d.StartTime > DateTime.Now); break;    //未开始

                case 3:
                    coll.Where(d => d.EndTime < DateTime.Now); break;    //已结束
                }
            }
            var datalist = coll.OrderByDescending(item => item.StartTime).ToPagedList(query.PageNo, query.PageSize);//

            var pageModel = new QueryPageModel <CollocationInfo>()
            {
                Models = datalist,
                Total  = datalist.TotalRecordCount
            };

            return(pageModel);
        }
コード例 #4
0
 /// <summary>
 /// 获取诊所添加的组合购列表
 /// </summary>
 /// <returns></returns>
 public static ObsoletePageModel <CollocationInfo> GetCollocationList(CollocationQuery query)
 {
     return(_iCollocationService.GetCollocationList(query));
 }
コード例 #5
0
        public PageModel <CollocationInfo> GetCollocationList(CollocationQuery query)
        {
            int num = 0;
            IQueryable <CollocationModel> collocationInfo =
                from a in context.CollocationInfo
                join b in context.ShopInfo on a.ShopId equals b.Id
                select new CollocationModel()
            {
                Id         = a.Id,
                CreateTime = a.CreateTime.Value,
                StartTime  = a.StartTime,
                EndTime    = a.EndTime,
                Title      = a.Title,
                ShortDesc  = a.ShortDesc,
                ShopName   = b.ShopName,
                ShopId     = a.ShopId,
                ProductId  = 0
            };

            collocationInfo =
                from a in collocationInfo
                join b in
                from t in context.CollocationPoruductInfo
                where t.IsMain
                select t on a.Id equals b.ColloId
                select new CollocationModel()
            {
                Id         = a.Id,
                CreateTime = a.CreateTime.Value,
                StartTime  = a.StartTime,
                EndTime    = a.EndTime,
                Title      = a.Title,
                ShortDesc  = a.ShortDesc,
                ShopName   = a.ShopName,
                ShopId     = a.ShopId,
                ProductId  = b.ProductId
            };

            if (!string.IsNullOrEmpty(query.Title))
            {
                collocationInfo =
                    from d in collocationInfo
                    where d.Title.Contains(query.Title)
                    select d;
            }
            if (query.ShopId.HasValue)
            {
                collocationInfo =
                    from d in collocationInfo
                    where d.ShopId == query.ShopId.Value
                    select d;
            }
            collocationInfo = collocationInfo.GetPage(out num, query.PageNo, query.PageSize, (IQueryable <CollocationModel> d) =>
                                                      from item in d
                                                      orderby item.CreateTime descending
                                                      select item);
            return(new PageModel <CollocationInfo>()
            {
                Models = collocationInfo,
                Total = num
            });
        }