public JsonResult UpdateActiveMarketCategory() { try { int id = Convert.ToInt32(Request.Params["id"] ?? "0"); int activeValue = Convert.ToInt32(Request.Params["active"] ?? "0"); _marketCategoryMgr = new MarketCategoryMgr(mySqlConnectionString); MarketCategory model = _marketCategoryMgr.GetMarketCategoryList(new MarketCategory { market_category_id = Convert.ToUInt32(id) }).FirstOrDefault(); model.market_category_status = activeValue; model.muser = (Session["caller"] as Caller).user_id; model.modified = DateTime.Now; if (_marketCategoryMgr.UpdateMarketCategory(model) > 0) { return Json(new { success = "true" }); } else { return Json(new { 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); return Json(new { success = "false" }); } }
public HttpResponseBase SaveMarketCategory() { string json = string.Empty; try { _marketCategoryMgr = new MarketCategoryMgr(mySqlConnectionString); MarketCategory query = new MarketCategory(); // MarketCategoryQuery model = new MarketCategoryQuery(); if (!string.IsNullOrEmpty(Request.Params["market_category_id"])) { query.market_category_id = Convert.ToUInt32(Request.Params["market_category_id"]); //model = _marketCategoryMgr.GetMarketCategoryList(query).FirstOrDefault(); } if (!string.IsNullOrEmpty(Request.Params["market_category_father_id"])) { query.market_category_father_id = Convert.ToInt32(Request.Params["market_category_father_id"]); } if (!string.IsNullOrEmpty(Request.Params["market_category_code"])) { query.market_category_code = Request.Params["market_category_code"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["market_category_name"])) { query.market_category_name = Request.Params["market_category_name"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["market_category_sort"])) { query.market_category_sort = Convert.ToInt32(Request.Params["market_category_sort"]); } if (!string.IsNullOrEmpty(Request.Params["market_category_status"])) { query.market_category_status = Convert.ToInt32(Request.Params["market_category_status"]); } int result = 0; if (query.market_category_id == 0)//新增 { query.kuser = (Session["caller"] as Caller).user_id; query.muser = query.kuser; query.created = DateTime.Now; query.modified = query.created; result = _marketCategoryMgr.InsertMarketCategory(query); } else//修改 { query.muser = (Session["caller"] as Caller).user_id; query.modified = DateTime.Now; result = _marketCategoryMgr.UpdateMarketCategory(query); } if (result > 0) { json = "{success:true}"; } else { json = "{success:true}"; } } 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; }