Exemplo n.º 1
0
 public HttpResponseBase IsSameChildVendor()
 {
     string result = string.Empty;
     try
     {
         List<ProductComboCustom> combos;
         if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
         {
             int parentId = int.Parse(Request.Params["ProductId"]);
             _combMgr = new ProductComboMgr(connectionString);
             combos = _combMgr.combQuery(new ProductComboCustom { Parent_Id = parentId });
         }
         else
         {
             Caller _caller = (Session["caller"] as Caller);
             _combTempMgr = new ProductComboTempMgr(connectionString);
             ProductComboCustom query = new ProductComboCustom { Writer_Id = _caller.user_id };
             //複製商品時
             if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
             {
                 query.Parent_Id = int.Parse(Request.Form["OldProductId"]);
             }
             combos = _combTempMgr.combQuery(query);
         }
         List<uint> brandIds = combos.GroupBy(m => m.brand_id).Select(m => m.Key).ToList();
         if (brandIds.Count == 1)
         {
             result = "{success:true,same:true}";
         }
         else
         {
             _vendorBrandMgr = new VendorBrandMgr(connectionString);
             List<uint> vendorIds = new List<uint>();
             VendorBrand vendorBrand;
             foreach (var id in brandIds)
             {
                 vendorBrand = _vendorBrandMgr.GetProductBrand(new VendorBrand { Brand_Id = id });
                 if (vendorBrand != null && !vendorIds.Contains(vendorBrand.Vendor_Id))
                 {
                     vendorIds.Add(vendorBrand.Vendor_Id);
                 }
             }
             result = "{success:true,same:" + (vendorIds.Count == 1).ToString().ToLower() + "}";
         }
     }
     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);
         result = "{success:true,same:false}";
     }
     this.Response.Clear();
     this.Response.Write(result);
     this.Response.End();
     return this.Response;
 }
Exemplo n.º 2
0
        public HttpResponseBase combSpecQuery()
        {
            resultStr = "{success:false}";
            try
            {
                int pileId = 0;
                int.TryParse(Request.Params["pileId"] ?? "0", out pileId);
                if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
                {
                    int parentId = int.Parse(Request.Params["ProductId"]);
                    _combMgr = new ProductComboMgr(connectionString);
                    resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_combMgr.combQuery(new ProductComboCustom { Parent_Id = parentId, Pile_Id = pileId })) + "}";
                }
                else
                {
                    Caller _caller = (Session["caller"] as Caller);
                    _combTempMgr = new ProductComboTempMgr(connectionString);
                    ProductComboCustom query = new ProductComboCustom { Writer_Id = _caller.user_id, Pile_Id = pileId };
                    //複製商品時
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.Parent_Id = int.Parse(Request.Form["OldProductId"]);
                    }
                    resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_combTempMgr.combQuery(query)) + "}";
                }
            }
            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);
            }

            Response.Clear();
            Response.Write(resultStr);
            Response.End();
            return this.Response;
        }