public JsonResult Notice(int Id) { OperationResult oper = new OperationResult(OperationResultType.Error, "操作异常"); OnlinePurchaseProduct online = _onlinePurchaseProductContract.View(Id); List <Store> listStore = _storeContract.Stores.Where(x => x.IsDeleted == false && x.IsEnabled == true && x.Administrators.Any()).ToList(); List <int> listAdminId = new List <int>(); foreach (Store item in listStore) { listAdminId.AddRange(item.Administrators.Where(x => x.IsDeleted == false && x.IsEnabled == true).Select(x => x.Id)); } string strContent = string.IsNullOrEmpty(online.NoticeContent) ? online.NoticeTitle : online.NoticeContent; NotificationDto dto = new NotificationDto() { AdministratorIds = listAdminId, Title = online.NoticeTitle, Description = strContent, IsEnableApp = true, NoticeTargetType = (int)NoticeTargetFlag.Admin, NoticeType = (int)NoticeFlag.Immediate }; oper = _notificationContract.Insert(sendNotificationAction, dto); return(Json(oper)); }
public ActionResult Create(string num = null) { OnlinePurchaseProductDto onlineDto = new OnlinePurchaseProductDto(); DateTime current = DateTime.Now; string strDate = current.ToString("yyyy-MM-dd 00:00:00"); string strEndDate = current.ToString("yyyy-MM-dd 23:23:59"); onlineDto.StartDate = DateTime.Parse(strDate); onlineDto.EndDate = DateTime.Parse(strEndDate); int Quantity = 0; if (num != null) { OnlinePurchaseProduct online = _onlinePurchaseProductContract.OnlinePurchaseProducts.FirstOrDefault(x => x.IsDeleted == false && x.IsEnabled == true && x.UniqueCode == num); if (online != null) { Quantity = online.OnlinePurchaseProductItems.Where(w => w.IsEnabled && !w.IsDeleted).Count(); Mapper.CreateMap <OnlinePurchaseProduct, OnlinePurchaseProductDto>(); onlineDto = Mapper.Map <OnlinePurchaseProduct, OnlinePurchaseProductDto>(online); CheckResultEdo edo = new CheckResultEdo(); edo.UniqueCode = onlineDto.UniqueCode; edo.ValidCount = Quantity; WriteCookie(edo); } } ViewBag.Quantity = Quantity; return(View(onlineDto)); }
/// <summary> /// 获取有效数据 /// </summary> /// <returns></returns> public async Task <ActionResult> ValidList() { GridRequest request = new GridRequest(Request); Expression <Func <OnlinePurchaseProductItem, bool> > predicate = FilterHelper.GetExpression <OnlinePurchaseProductItem>(request.FilterGroup); CheckResultEdo edo = ReadCookie(Request); var data = await Task.Run(() => { int count = 0; int pageIndex = request.PageCondition.PageIndex; int pageSize = request.PageCondition.PageSize; IQueryable <Product> listProduct = _productContract.Products.Where(w => w.IsEnabled && !w.IsDeleted); OnlinePurchaseProduct onlinePurchaseProduct = _onlinePurchaseProductContract.OnlinePurchaseProducts.FirstOrDefault(x => x.UniqueCode == edo.UniqueCode); List <string> listNumber = onlinePurchaseProduct.OnlinePurchaseProductItems.AsQueryable() .Where <OnlinePurchaseProductItem, int>(predicate, request.PageCondition, out count) .Select(x => x.BigProdNum).Distinct().ToList(); List <ProductEdo> listProductEdo = new List <ProductEdo>(); List <Product> listEntity = listProduct.Where(x => listNumber.Any(k => k == x.BigProdNum) == true).ToList(); string strColor = string.Empty; string strSize = string.Empty; string strImagePath = string.Empty; string strBrandName = string.Empty; string strCategoryName = string.Empty; foreach (string number in listNumber) { IEnumerable <Product> entities = listEntity.Where(x => x.BigProdNum == number); List <string> listColors = listEntity.Select(x => x.Color.ColorName).Distinct().ToList(); List <string> listSize = listEntity.Select(x => x.Size.SizeName).Distinct().ToList(); strColor = ExpendTostring(listColors); strSize = ExpendTostring(listSize); Product product = entities.FirstOrDefault(); strImagePath = product.ProductOriginNumber.ThumbnailPath; strBrandName = product.ProductOriginNumber == null ? "" : product.ProductOriginNumber.Brand.BrandName; strCategoryName = product.ProductOriginNumber == null ? "" : product.ProductOriginNumber.Category.CategoryName; listProductEdo.Add(new ProductEdo { Id = number, ColorName = strColor, SizeName = strSize, ImagePath = strImagePath, ColorCount = listColors.Count(), SizeCount = listSize.Count(), BrandName = strBrandName, CategoryName = strCategoryName, BigProdNum = number }); } return(new GridData <object>(listProductEdo, count, request.RequestInfo)); }); return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult View(int Id) { OnlinePurchaseProduct entity = _onlinePurchaseProductContract.View(Id); return(PartialView(entity)); }