Пример #1
0
        public JsonResult edit(Models.DbModels.api model)
        {
            if (string.IsNullOrEmpty(model.apititle))
            {
                return(Json(new { code = -1, msg = "请输入接口标题" }));
            }
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();

                Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
                try
                {
                    if (model.apiid == 0)
                    {
                        if (Models.ApiDal.Instance.Add(PubConn, model))
                        {
                            model.apiid = PubConn.GetIdentity();
                            return(Json(new { code = 1, response = model }));
                        }
                        else
                        {
                            return(Json(new { code = -1, msg = "添加失败" }));
                        }
                    }
                    else
                    {
                        if (Models.ApiDal.Instance.Edit(PubConn, model))
                        {
                            return(Json(new { code = 1, response = model }));
                        }
                        else
                        {
                            return(Json(new { code = -1, msg = "修改失败" }));
                        }
                    }
                }
                finally
                {
                    log.opecontent = "修改接口";
                    Models.CertCenterLogDal.Instance.Add(PubConn, log);
                }
            }
        }