Example #1
0
        public HttpResponseBase GetProductInfo()
        {
            string resultJson = "{success:false}";
            _productMgr = new ProductMgr(mySqlConnectionString);

            int isTranInt = 0;
            if (int.TryParse(Request.Params["Product_id"].ToString(), out isTranInt))
            {
                List<QueryandVerifyCustom> pros = _productMgr.GetProductInfoByID(Request.Params["Product_id"].ToString());
                if (pros.Count > 0)
                {
                    int packet_id = Convert.ToInt32(Request.Params["Packet_id"].ToString());
                    _elementDetailMgr = new ElementDetailMgr(mySqlConnectionString);
                    List<ElementDetailQuery> store = _elementDetailMgr.QueryPacketProd(new ElementDetail { packet_id = packet_id, element_content = isTranInt.ToString() });
                    if (store.Count != 0)
                    {
                        bool repeat = true;
                        if (!string.IsNullOrEmpty(Request.Params["Element_id"].ToString()))
                        {
                            int element_id = Convert.ToInt32(Request.Params["Element_id"].ToString());
                            foreach (var item in store)
                            {
                                if (item.element_id == element_id)
                                {
                                    repeat = false;
                                    resultJson = "{success:true,msg:0}";
                                    break;
                                }
                            }
                            if (repeat)
                            {
                                resultJson = "{success:true,msg:1}";
                            }
                        }
                        else
                        {
                            resultJson = "{success:true,msg:1}";
                        }
                    }
                    else
                    {
                        resultJson = "{success:true,msg:0}";
                    }
                }
            }
            this.Response.Clear();
            this.Response.Write(resultJson);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase GetInfoByProductID(string ProductIDs)
        {
            string json = string.Empty;
            try
            {
                _prodMgr = new ProductMgr(connectionString);
                int totalCount = 0;
                List<QueryandVerifyCustom> pros = _prodMgr.GetProductInfoByID(ProductIDs);
                totalCount = pros.Count;

                json = new JObject(
                    new JProperty("succes", true),
                    new JProperty("totalCount", totalCount),
                    new JProperty("item", new JArray(
                       from p in pros
                       select new JObject(
                           new JProperty("product_image", p.product_image != "" ? (imgServerPath + prod50Path + GetDetailFolder(p.product_image) + p.product_image) : defaultImg),
                           new JProperty("product_id", p.product_id),
                           new JProperty("brand_name", p.brand_name),
                           new JProperty("product_name", p.product_name.Replace(Product.L_KH + p.prod_sz + Product.R_KH, "")),
                           new JProperty("prod_sz", p.prod_sz),
                           new JProperty("combination", p.combination),
                           new JProperty("combination_id", p.combination_id),
                           new JProperty("price_type", p.price_type),
                           new JProperty("price_type_id", p.price_type_id),
                           new JProperty("product_status", p.product_status),
                           new JProperty("price", p.price),
                           new JProperty("cost", p.cost),
                           new JProperty("gigade_price", p.price),
                           new JProperty("gigade_cost", p.cost),
                           new JProperty("event_price", p.event_price),
                           new JProperty("event_cost", p.event_cost),
                           new JProperty("event_start", CommonFunction.GetNetTime(p.event_start).ToString("yyyy/MM/dd HH:mm:ss")),
                           new JProperty("event_end", CommonFunction.GetNetTime(p.event_end).ToString("yyyy/MM/dd HH:mm:ss")),
                           new JProperty("prepaid", p.prepaid)
                           )))
                    ).ToString();
                // json = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(pros) + "}";
            }
            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 = "{succes:true,totalCount:0,item:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }