public async Task <IActionResult> OnPostSkuListAsync(long ProductId) { ProductSkuSearch where = new ProductSkuSearch(); where.ProductId = ProductId; var list = await _skuService.GetListAsync(where, "OrderIndex asc"); return(PagerData(list, 1, 999, list.Count)); }
public async Task <IActionResult> Edit(long?id) { //生成编辑ID,sku变动时根据此ID来操作缓存数据 var EditID = ID.NewID(); ViewData["EditID"] = EditID; if (id.HasValue) { //编辑 var model = await _service.GetByIdAsync(id.Value); if (model == null) { throw new VinoDataNotFoundException("无法取得数据!"); } //取得所有sku并保存到缓存 ProductSkuSearch where = new ProductSkuSearch(); where.ProductId = model.Id; var skus = await _skuService.GetListAsync(where, null); if (skus == null) { skus = new List <ProductSkuDto>(); } foreach (var sku in skus) { sku.ModifyStatus = Domain.Enum.EmEntityModifyStatus.UnChange; } var cacheKey = string.Format(CacheKeyDefinition.ProductSkuTemp, EditID); _cacheService.Add(cacheKey, skus, new TimeSpan(10, 0, 0)); //取得商品类目数据 var dict = new Dictionary <int, long>(); if (model.CategoryId.HasValue) { (await _productCategoryService.GetWithParentsAsync(model.CategoryId.Value)).ForEach(x => dict.Add(x.Level, x.Id)); } ViewBag.Category = JsonConvert.SerializeObject(dict); ViewData["Mode"] = "Edit"; return(View(model)); } else { //新增 ProductDto dto = new ProductDto(); ViewBag.Category = ""; ViewData["Mode"] = "Add"; return(View(dto)); } }