Exemple #1
0
        /// <summary>
        /// 保存代理商
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public JsonResult SaveAgent(string data)
        {
            Agent agentBll = new Agent();

            TB_DATA_AGENT agentobj = (TB_DATA_AGENT)Newtonsoft.Json.JsonConvert.DeserializeObject(data, typeof(TB_DATA_AGENT));

            if (!String.IsNullOrEmpty(agentobj.AGENT_ID))
            {
                Dictionary <string, object> dic = ConvertJson.JsonToDictionary(data);
                agentobj.Attach();
                agentobj.SetModifiedProperties(dic);
                agentobj.LAST_UPDATED_BY   = HttpContext.Session["UserId"].ToString();
                agentobj.LAST_UPDATED_TIME = DateTime.Now;
            }
            else
            {
                agentobj.AGENT_ID          = Guid.NewGuid().ToString();
                agentobj.STATUS            = 1;
                agentobj.CREATED_BY        = HttpContext.Session["UserId"].ToString();
                agentobj.CREATED_TIME      = DateTime.Now;
                agentobj.LAST_UPDATED_BY   = HttpContext.Session["UserId"].ToString();
                agentobj.LAST_UPDATED_TIME = DateTime.Now;
            }
            int flag = agentBll.SaveAgent(agentobj);

            if (flag == 1)
            {
                return(Json(new { error = 1, msg = "保存成功" }, JsonRequestBehavior.AllowGet));
            }
            if (flag == -1)
            {
                return(Json(new { error = -1, msg = "输入的账号已经存在,请重新输入!" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { error = 0, msg = "保存失败" }, JsonRequestBehavior.AllowGet));
            }
        }