Ejemplo n.º 1
0
        public HttpResponseBase SaveDescription()
        {
            string json = string.Empty;
            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writeId = (int)vendorModel.vendor_id;
                string tags = Request.Form["Tags"] ?? "";
                string notices = Request.Form["Notice"] ?? "";
                JavaScriptSerializer jsSer = new JavaScriptSerializer();
                _productTempMgr = new ProductTempMgr(connectionString);
                string product_id = string.Empty;
                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
                {
                    product_id = Request.Form["ProductId"].ToString();
                }
                //if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                //{
                //    product_id = Request.Form["OldProductId"].ToString();
                //}
                if (!string.IsNullOrEmpty(product_id))
                {
                    ProductTemp oldProdTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { Product_Id = product_id, Combo_Type = COMBO_TYPE, Create_Channel = 2, Writer_Id = writeId }).FirstOrDefault();
                    if (oldProdTemp != null)
                    {
                        oldProdTemp.Page_Content_1 = Request.Form["page_content_1"] ?? "";
                        oldProdTemp.Page_Content_2 = Request.Form["page_content_2"] ?? "";
                        oldProdTemp.Page_Content_3 = Request.Form["page_content_3"] ?? "";
                        oldProdTemp.Product_Keywords = Request.Form["product_keywords"] ?? "";
                        if (!string.IsNullOrEmpty(Request.Form["product_buy_limit"]))
                        {
                            oldProdTemp.Product_Buy_Limit = uint.Parse(Request.Form["product_buy_limit"]);
                        }
                        oldProdTemp.Writer_Id = writeId;
                        oldProdTemp.Combo_Type = COMBO_TYPE;

                        List<ProductTagSetTemp> tagTemps = jsSer.Deserialize<List<ProductTagSetTemp>>(tags);
                        foreach (ProductTagSetTemp item in tagTemps)
                        {
                            item.Writer_Id = writeId;
                            item.Combo_Type = COMBO_TYPE;
                            item.product_id = oldProdTemp.Product_Id;
                        }
                        List<ProductNoticeSetTemp> noticeTemps = jsSer.Deserialize<List<ProductNoticeSetTemp>>(notices);
                        //noticeTemps.ForEach(m => m.Writer_Id = writer_id);
                        foreach (ProductNoticeSetTemp item in noticeTemps)
                        {
                            item.Writer_Id = writeId;
                            item.Combo_Type = COMBO_TYPE;
                            item.product_id = oldProdTemp.Product_Id;
                        }
                        _productTempMgr = new ProductTempMgr(connectionString);
                        if (_productTempMgr.VendorDescriptionInfoUpdate(oldProdTemp, tagTemps, noticeTemps))
                        {
                            json = "{success:true}";
                        }
                        else
                        {
                            json = "{success:false}";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }