Exemple #1
0
        public ResponseMessageResult Post(sh_business_appinfo sh_business_appinfo)
        {
            JwtModel jwtmodel = JwtHelper.getToken(HttpContext.Current.Request.Headers.GetValues("Authorization").First().ToString());

            if (jwtmodel.isadmin)
            {
                var info = db.sh_business_appinfo.Where(o => o.sh_appid == sh_business_appinfo.sh_appid).Count();
                if (info > 0)
                {
                    model.message     = "appid已经存在";
                    model.status_code = 401;
                }
                else
                {
                    db.sh_business_appinfo.Add(sh_business_appinfo);
                    try
                    {
                        db.SaveChanges();
                        model.message     = "新增成功";
                        model.status_code = 200;
                    }
                    catch (Exception ex)
                    {
                        model.message     = ex.Message;
                        model.status_code = 401;
                    }
                }
            }
            else
            {
                model.message     = "用户权限不足";
                model.status_code = 401;
            }
            return(new ResponseMessageResult(Request.CreateResponse((HttpStatusCode)model.status_code, model)));
        }
Exemple #2
0
        public ResponseMessageResult Putsh_business_appinfo(sh_business_appinfo sh_business_appinfo)
        {
            JwtModel jwtmodel = JwtHelper.getToken(HttpContext.Current.Request.Headers.GetValues("Authorization").First().ToString());

            if (jwtmodel.isadmin)
            {
                var count = db.sh_business_appinfo.Where(o => o.sh_appid == sh_business_appinfo.sh_appid && o.id != sh_business_appinfo.id).Count();
                if (count > 0)
                {
                    model.message     = "appid已经存在";
                    model.status_code = 401;
                }
                else
                {
                    //db.Entry(sh_business_appinfo).State = EntityState.Modified;
                    var info = db.sh_business_appinfo.Find(sh_business_appinfo.id);
                    if (!string.IsNullOrEmpty(sh_business_appinfo.sh_password))
                    {
                        info.sh_password = BaseHelper.Md5Hash(sh_business_appinfo.sh_password);
                    }
                    info.sh_appid        = sh_business_appinfo.sh_appid;
                    info.sh_appsecret    = sh_business_appinfo.sh_appsecret;
                    info.sh_storeid      = sh_business_appinfo.sh_storeid;
                    info.sh_storename    = sh_business_appinfo.sh_storename;
                    info.sh_businessname = sh_business_appinfo.sh_businessname;
                    info.sh_mobile       = sh_business_appinfo.sh_mobile;
                    info.sh_balance      = sh_business_appinfo.sh_balance;
                    info.sh_commission   = sh_business_appinfo.sh_commission;
                    info.sh_commratio    = sh_business_appinfo.sh_commratio;
                    info.agid            = sh_business_appinfo.agid;
                    info.status          = sh_business_appinfo.status;
                    info.isused          = sh_business_appinfo.isused;
                    try
                    {
                        model.message     = "修改成功";
                        model.status_code = 200;
                        db.SaveChanges();
                    }
                    catch (DbUpdateConcurrencyException ex)
                    {
                        model.message     = ex.Message;
                        model.status_code = 401;
                    }
                }
            }
            else
            {
                model.message     = "用户权限不足";
                model.status_code = 401;
            }
            return(new ResponseMessageResult(Request.CreateResponse((HttpStatusCode)model.status_code, model)));
        }