public ActionResult SaveForm(string keyValue, AdvertisementEntity entity)
 {
     advertisementbll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }
        public HttpResponseMessage SaveAdvertisement(SaveAdvertisementArgEntity arg)
        {
            BaseJson <string> resultMsg = new BaseJson <string> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(AdvertisementController), arg.TryToJson(), "保存广告-SaveAdvertisement", () =>
            {
                if (!string.IsNullOrEmpty(arg.t) && !string.IsNullOrEmpty(arg.Appkey) && !string.IsNullOrEmpty(arg.AccessToken))
                {
                    if (arg.t.CheckTimeStamp())
                    {
                        //获取缓存Token信息
                        Token_Preview token = CacheFactory.Cache().GetCache <Token_Preview>(arg.Appkey);
                        if (token != null)
                        {
                            //校验授权码
                            string tokenStr = token.AccessToken;
                            if (!string.IsNullOrEmpty(tokenStr) && tokenStr.Equals(arg.AccessToken))
                            {
                                AdvertisementEntity entity = new AdvertisementEntity
                                {
                                    Title          = arg.Title,
                                    Category       = arg.Which == "0" ? "主站" : arg.Which == "1" ? "开奖网" : arg.Which == "2" ? "手机站" : "",
                                    CategoryId     = arg.Which,
                                    Position       = arg.Position,
                                    Href           = arg.Href,
                                    TermOfValidity = arg.OverTime
                                };

                                if (!string.IsNullOrEmpty(arg.Id))
                                {
                                    entity.IsEnable = true;
                                    advertisementBll.SaveForm(arg.Id, entity);
                                }
                                else
                                {
                                    AdvertisementEntity temp = advertisementBll.GetEntity(a => a.CategoryId.Equals(arg.Which) && a.Position == arg.Position);
                                    if (temp != null)
                                    {
                                        entity.IsEnable = true;
                                        advertisementBll.SaveForm(temp.ID, entity);
                                    }
                                }

                                //清理缓存
                                Cache.Factory.CacheFactory.Cache().RemoveCache("Advertisement_Html_" + arg.Which);

                                resultMsg = new BaseJson <string>
                                {
                                    Status  = (int)JsonObjectStatus.Success,
                                    Data    = null,
                                    Message = JsonObjectStatus.Success.GetEnumText(),
                                    BackUrl = null
                                };
                            }
                            else
                            {
                                resultMsg = new BaseJson <string>
                                {
                                    Status  = (int)JsonObjectStatus.TokenInvalid,
                                    Data    = null,
                                    Message = JsonObjectStatus.TokenInvalid.GetEnumText(),
                                    BackUrl = null
                                };
                            }
                        }
                        else
                        {
                            resultMsg = new BaseJson <string>
                            {
                                Status  = (int)JsonObjectStatus.TokenInvalid,
                                Data    = null,
                                Message = JsonObjectStatus.TokenInvalid.GetEnumText(),
                                BackUrl = null
                            };
                        }
                    }
                    else
                    {
                        resultMsg = new BaseJson <string>
                        {
                            Status  = (int)JsonObjectStatus.Fail,
                            Data    = null,
                            Message = JsonObjectStatus.Fail.GetEnumText() + ",无效参数。",
                            BackUrl = null
                        };
                    }
                }
                else
                {
                    resultMsg = new BaseJson <string>
                    {
                        Status  = (int)JsonObjectStatus.Fail,
                        Data    = null,
                        Message = JsonObjectStatus.Fail.GetEnumText() + ",请求参数为空。",
                        BackUrl = null
                    };
                }
            }, e =>
            {
                resultMsg = new BaseJson <string>
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };
            });

            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }