Example #1
0
        public JsonResult CollcationViewList(string uid)
        {
            var id   = _storeProductCollocationContract.StoreProductCollocations.Where(o => o.Guid == uid).Select(x => x.Id).FirstOrDefault();
            var requ = new GridRequest(Request);
            var pred = FilterHelper.GetExpression <Product>(requ.FilterGroup);

            var querySouce = from item in _storeCollocationInfoContract.StoreCollocationInfos
                             join product in _productContract.Products on item.ProductOrigNumberId equals product.Id into Joinitem
                             from product in Joinitem.DefaultIfEmpty()
                             where item.IsDeleted == false && item.IsEnabled == true &&
                             product.IsDeleted == false && product.IsEnabled == true &&
                             item.StoreCollocationId == id
                             select new
            {
                item.Id,
                product.ThumbnailPath,
                product.ProductNumber,
                product.ProductOriginNumber,
                product.Size,
                product.Color
            };



            var da = querySouce.OrderByDescending(c => c.Id)
                     .Skip(requ.PageCondition.PageIndex)
                     .Take(requ.PageCondition.PageSize)
                     .Select(c => new
            {
                Id       = c.Id,
                ParentId = "",
                c.ThumbnailPath,
                c.ProductNumber,
                c.ProductOriginNumber.Brand.BrandName,
                c.Size.SizeName,
                c.Color.ColorName,
                c.ProductOriginNumber.Season.SeasonName,
                c.ProductOriginNumber.Category.CategoryName
            }).ToList();
            GridData <Object> objdata = new GridData <object>(da, querySouce.Count(), Request);

            return(Json(objdata));
        }
Example #2
0
        public ActionResult List()
        {
            OperationResult resul   = new OperationResult(OperationResultType.Error);
            GridRequest     request = new GridRequest(Request);
            string          storeId = Request["StoreId"];
            Expression <Func <StoreProductCollocation, bool> > predicate = FilterHelper.GetExpression <StoreProductCollocation>(request.FilterGroup);
            var spd        = _storeProductCollocationContract.StoreProductCollocations.Where(predicate).Where(x => x.CollocationName != "").Include(x => x.Operator).ToList();
            var filterList = new List <StoreProductCollocation>();

            if (!string.IsNullOrEmpty(storeId) && storeId != "0")
            {
                foreach (var item in spd)
                {
                    var arry = GetStoreNameArry(item.StoreId);
                    if (arry.Contains(storeId))
                    {
                        filterList.Add(item);
                    }
                }
            }
            else
            {
                filterList = spd.ToList();
            }
            int count  = filterList.ToList().Count();
            var source = filterList.OrderByDescending(c => c.CreatedTime)
                         .Skip(request.PageCondition.PageIndex)
                         .Take(request.PageCondition.PageSize);
            List <object> lis = new List <object>();

            foreach (var item in source)
            {
                if (item.Guid != null)
                {
                    var id         = _storeProductCollocationContract.StoreProductCollocations.Where(o => o.Guid == item.Guid).Select(x => x.Id).FirstOrDefault();
                    var querySouce = from Chitem in _storeCollocationInfoContract.StoreCollocationInfos
                                     join product in _productContract.Products on Chitem.ProductOrigNumberId equals product.Id into Joinitem
                                     from product in Joinitem.DefaultIfEmpty()
                                     where Chitem.IsDeleted == item.IsDeleted && Chitem.IsEnabled == item.IsEnabled &&
                                     Chitem.StoreCollocationId == id
                                     select new
                    {
                        Chitem.Id,
                        product.ThumbnailPath,
                        product.ProductNumber,
                        product.ProductOriginNumber,
                        product.Size,
                        product.Color,
                        product.CreatedTime,
                        product.IsDeleted,
                        product.IsEnabled,
                        Chitem.Operator
                    };



                    var da = querySouce.OrderByDescending(c => c.Id)
                             .Select(c => new
                    {
                        Id       = "childStore" + c.Id,
                        ParentId = "par" + id,
                        Guid     = "",
                        c.ThumbnailPath,
                        CollocationName = c.ProductNumber,
                        c.ProductOriginNumber.TagPrice,
                        StoreId     = "",
                        CreatedTime = c.CreatedTime,
                        c.IsDeleted,
                        c.IsEnabled,
                        c.Operator.Member.MemberName
                    }).ToList();
                    int childCount = da.ToList().Count();
                    count += childCount;
                    var par = new
                    {
                        Id              = "par" + item.Id,
                        Guid            = item.Guid,
                        ParentId        = "",
                        ThumbnailPath   = item.ThumbnailPath,
                        CollocationName = item.CollocationName,
                        count           = childCount,
                        TagPrice        = "",
                        StoreId         = GetCount(item.StoreId),
                        CreatedTime     = item.CreatedTime,
                        item.IsDeleted,
                        item.IsEnabled,
                        MemberName = item.Operator == null ? "" : item.Operator.Member.MemberName
                    };
                    lis.Add(par);
                    lis.AddRange(da);
                }
                else
                {
                    var par = new
                    {
                        Id              = "par" + item.Id,
                        Guid            = item.Guid,
                        ParentId        = "",
                        ThumbnailPath   = item.ThumbnailPath,
                        CollocationName = item.CollocationName,
                        count           = 0,
                        TagPrice        = "",
                        StoreId         = GetCount(item.StoreId),
                        CreatedTime     = item.CreatedTime,
                        item.Operator.Member.MemberName
                    };
                    lis.Add(par);
                }
            }
            GridData <object> data = new GridData <object>(lis, count, request.RequestInfo);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }