private void GetStoreMarketing(HttpContext context) { ProductBrowseQuery productBrowseQuery = new ProductBrowseQuery(); productBrowseQuery.PageIndex = context.Request["pageIndex"].ToInt(0); productBrowseQuery.PageSize = context.Request["pageSize"].ToInt(0); int storeId = 0; int.TryParse(context.Request["storeId"], out storeId); productBrowseQuery.StoreId = storeId; int imageId = 0; int.TryParse(context.Request["imageId"], out imageId); StoreMarketingImagesInfo storeMarketingImages = MarketingImagesHelper.GetStoreMarketingImages(storeId, imageId); if (storeMarketingImages != null) { productBrowseQuery.CanUseProducts = storeMarketingImages.ProductIds; if (context.Request["isShowServiceProduct"].ToInt(0) > 0) { productBrowseQuery.ProductType = ProductType.PhysicalProduct; } DbQueryResult storeProductList = StoresHelper.GetStoreProductList(productBrowseQuery); string s = JsonConvert.SerializeObject(storeProductList); context.Response.ContentType = "text/json"; context.Response.Write(s); } }
protected void Page_Load(object sender, EventArgs e) { try { int imageId = base.Request.QueryString["ImageId"].ToInt(0); int storeId = HiContext.Current.Manager.StoreId; MarketingImagesInfo marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(imageId); if (marketingImagesInfo != null) { StoreMarketingImagesInfo storeMarketingImages = MarketingImagesHelper.GetStoreMarketingImages(storeId, imageId); IList <StoreProductBaseModel> list = null; if (storeMarketingImages != null) { string safeIDList = Globals.GetSafeIDList(storeMarketingImages.ProductIds, ',', true); if (safeIDList != "") { list = StoresHelper.GetStoreProductBaseInfo(storeMarketingImages.ProductIds, storeId); } } if (list == null) { list = new List <StoreProductBaseModel>(); } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { if (stringBuilder.Length > 0) { stringBuilder.Insert(0, list[i].ProductId + "|||" + list[i].ProductName + ",,,"); } else { stringBuilder.Append(list[i].ProductId + "|||" + list[i].ProductName); } } this.hidSelectProducts.Value = stringBuilder.ToString(); this.txtImageName.Value = marketingImagesInfo.ImageName; this.txtDescription.Value = marketingImagesInfo.Description; this.txtImageName.Disabled = true; this.txtDescription.Disabled = true; } } catch (Exception ex) { base.Response.Write(ex.Message); } }
public override void OnLoad(HttpContext context) { base.OnLoad(context); if (context.Request["flag"] == "Select") { int storeId = base.CurrentManager.StoreId; int num = context.Request["pageIndex"].ToInt(0); if (num <= 0) { num = 1; } int num2 = context.Request["pageSize"].ToInt(0); if (num2 < 1) { num2 = 10; } MarketingImagesQuery marketingImagesQuery = new MarketingImagesQuery(); marketingImagesQuery.PageIndex = num; marketingImagesQuery.PageSize = num2; marketingImagesQuery.SortOrder = SortAction.Desc; marketingImagesQuery.SortBy = "ImageId"; PageModel <MarketingImagesInfo> marketingImages = MarketingImagesHelper.GetMarketingImages(marketingImagesQuery); string s = JsonConvert.SerializeObject(new { Result = new { RecordCount = marketingImages.Total, List = from i in marketingImages.Models select new { ImageId = i.ImageId, ImageName = i.ImageName, ImageUrl = this.GetImageFullPath(i.ImageUrl), Description = i.Description } } }); context.Response.Write(s); context.Response.End(); } if (context.Request["flag"] == "Mdy") { int storeId2 = base.CurrentManager.StoreId; int imageId = context.Request["ImageId"].ToInt(0); string idList = context.Request["ProductIds"].ToNullString(); MarketingImagesInfo marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(imageId); if (marketingImagesInfo == null) { context.Response.Write(this.GetErrorJosn(701, ((Enum)(object)ApiErrorCode.ImageIdNotExists_Error).ToDescription())); } else { idList = Globals.GetSafeIDList(idList, ',', true); if (string.IsNullOrEmpty(idList)) { context.Response.Write(this.GetErrorJosn(101, ((Enum)(object)ApiErrorCode.Paramter_Error).ToDescription())); } else { StoreMarketingImagesInfo storeMarketingImagesInfo = MarketingImagesHelper.GetStoreMarketingImages(storeId2, imageId); string text = ""; if (storeMarketingImagesInfo != null) { string safeIDList = Globals.GetSafeIDList(storeMarketingImagesInfo.ProductIds, ',', true); if (safeIDList != "") { string[] array = idList.Split(','); foreach (string str in array) { if (!("," + safeIDList + ",").Contains("," + str + ",")) { text = text + str + ","; } } } } else { storeMarketingImagesInfo = new StoreMarketingImagesInfo(); storeMarketingImagesInfo.StoreId = storeId2; storeMarketingImagesInfo.ImageId = imageId; } if (!string.IsNullOrEmpty(text)) { StoreMarketingImagesInfo storeMarketingImagesInfo2 = storeMarketingImagesInfo; storeMarketingImagesInfo2.ProductIds += ("," + text).TrimEnd(','); } else { storeMarketingImagesInfo.ProductIds = idList.TrimEnd(','); } MarketingImagesHelper.UpdateStoreMarketingImages(storeMarketingImagesInfo); string s2 = JsonConvert.SerializeObject(new { Result = new { Success = new { Status = true, Msg = string.Empty } } }); context.Response.Write(s2); context.Response.End(); } } } }