Ejemplo n.º 1
0
        public JsonResult <object> OpenArticle()
        {
            BaseModel   baseInfo = new BaseModel();
            HttpRequest re       = HttpContext.Current.Request;
            var         headers  = re.Headers;
            var         ApiKey   = headers.Get("ApiKey");

            if (!string.IsNullOrEmpty(ApiKey))
            {
                baseInfo = GetBaseInfo();
            }

            //当前时间
            var time = DateTime.Now;

            //是否开放
            if (time.TimeOfDay > OpeningHours || time.TimeOfDay < ClosingTime || IsShowArticle)
            {
                var model = _articleService.GetData(baseInfo?.UnionID);
                if (model != null)
                {
                    _articleService.AddViews(model.ID);
                }
                return(JsonNet(model));
            }

            return(JsonError("当前未开开放,开放时间:" + OpeningHours.ToString() + " - " + ClosingTime.ToString()));
        }