public JsonResult GetList(int PageIndex = 1, int PageSize = 10) { try { string strColorId = Request["ColorId"]; string strProductAttrId = Request["ProductAttrId"]; string strCategoryId = Request["CategoryId"]; IQueryable <Product> listProduct = _productContract.Products.Where(x => x.IsDeleted == false && x.IsEnabled == true && x.ProductOriginNumber.IsVerified == CheckStatusFlag.通过); List <int> listIds = this.GetStore(); IQueryable <Inventory> listInventory = _inventoryContract.Inventorys.Where(x => x.IsDeleted == false && x.IsEnabled == true && listIds.Contains(x.StorageId) && x.Status == 0 && x.IsLock == false);//库存状态 0:待采购 1:已采购,未出库 2:已出库 3:欠损 4:退货 if (!string.IsNullOrEmpty(strColorId)) { int colorId = int.Parse(strColorId); listInventory = listInventory.Where(x => x.Product.ColorId == colorId); } if (!string.IsNullOrEmpty(strProductAttrId)) { int productAttrId = int.Parse(strProductAttrId); listInventory = listInventory.Where(x => x.Product.ProductOriginNumber.ProductAttributes.Where(k => k.Id == productAttrId).Count() > 0); } if (!string.IsNullOrEmpty(strCategoryId)) { int categoryId = int.Parse(strCategoryId); List <int> listCategoryId = _categotyContract.View(categoryId).Children.Select(x => x.Id).ToList(); listInventory = listInventory.Where(x => listCategoryId.Contains(x.Product.ProductOriginNumber.CategoryId)); } listInventory = listInventory.OrderByDescending(x => x.CreatedTime).Skip((PageIndex - 1) * PageSize).Take(PageSize); IQueryable <Comment> listComment = _commentContract.Comments.Where(x => x.CommentSource == (int)CommentSourceFlag.StoreProduct && x.IsDeleted == false && x.IsEnabled == true); //int approvalCount = _approvalContract.Approvals.Where(x => x.IsDeleted == false && x.IsEnabled == true && x.MemberId == memberId).Count(); var data = listInventory.Select(x => new { x.ProductId, CoverImagePath = string.IsNullOrEmpty(x.Product.ProductCollocationImg) ? x.Product.ThumbnailPath : x.Product.ProductCollocationImg, Price = x.Product.ProductOriginNumber.TagPrice, ColorName = x.Product.Color.ColorName, ColorPath = x.Product.Color.IconPath, SizeName = x.Product.Size.SizeName, SeasonName = x.Product.ProductOriginNumber.Season.SeasonName, CategoryName = x.Product.ProductOriginNumber.Category.CategoryName, x.Product.ProductOriginNumber.JumpLink, CommentCount = listComment.Where(k => k.SourceId == x.ProductId).Count(), //IsApproval = approvalCount > 0 ? (int)IsApproval.Yes : (int)IsApproval.No, //ImageSize = System.IO.File.Exists(FileHelper.UrlToPath(x.Product.ProductCollocationImg ?? x.Product.ThumbnailPath)) ? "{" + Image.FromFile(FileHelper.UrlToPath(x.Product.ProductCollocationImg ?? x.Product.ThumbnailPath)).Width.ToString() + "," + Image.FromFile(FileHelper.UrlToPath(x.Product.ProductCollocationImg ?? x.Product.ThumbnailPath)).Height.ToString() + "}" : string.Empty, }); return(Json(new OperationResult(OperationResultType.Success, string.Empty, data))); } catch (Exception ex) { _Logger.Error <string>(ex.ToString()); return(Json(new OperationResult(OperationResultType.Error, "服务器忙,请稍后重试"), JsonRequestBehavior.AllowGet)); } }
public ActionResult View(int Id) { var result = _categoryContract.View(Id); return(PartialView(result)); }