Esempio n. 1
0
        public JsonResult updateDetail(Entity.DetailInfo info, string pics, int cid, string content, string key, string verifykey)
        {
            if (this.config.EnabledDetailVerifykey)
            {
                if (string.IsNullOrEmpty(key))
                {
                    key = "verifycode";
                }
                var code = Config.UserConfig.getVerifyCode(key);
                if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower()))
                {
                    return(this.getResult(Entity.Error.错误, "验证码错误!"));
                }
            }
            if (info == null || string.IsNullOrEmpty(info.ChannelCode))
            {
                return(this.getResult(Entity.Error.错误, "频道错误!"));
            }
            if (string.IsNullOrEmpty(pics) && string.IsNullOrEmpty(content))
            {
                return(this.getResult(Entity.Error.错误, "内容为空!"));
            }
            using (var manage = new bitcms.Data.CMSManage())
            {
                if (this.config.VerifyUserDetail)
                {
                    info.Display = 0;
                }

                if (info.ItemId > 0)
                {
                    info.Items = info.ItemId.ToString();
                }
                info.UserId = this.userOnlineInfo.UserId;
                info.Author = this.userOnlineInfo.UserName;
                if (string.IsNullOrEmpty(info.Source))
                {
                    info.Source = this.config.SiteName;
                }
                manage.updateDetail(info);
                if (info.DetailId > 0)
                {
                    if (!string.IsNullOrEmpty(content))
                    {
                        var contentInfo = new Entity.DetailContentInfo()
                        {
                            Title       = info.Title,
                            Content     = content,
                            OrderNo     = 0,
                            DetailId    = info.DetailId,
                            ContentId   = cid,
                            ItemId      = info.ItemId,
                            ChannelCode = info.ChannelCode,
                            InDate      = Config.SiteConfig.getLocalTime()
                        };
                        manage.updateDetailContent(contentInfo);
                    }
                    if (!string.IsNullOrEmpty(pics))
                    {
                        //更新图库
                        JavaScriptSerializer jsHelper = new JavaScriptSerializer();
                        var gallerylist = jsHelper.Deserialize <List <Entity.DetailGalleryInfo> >(pics);
                        if (gallerylist != null)
                        {
                            manage.updateDetailGallery(gallerylist, info.DetailId);
                        }
                    }
                }
                if (info.Display != 1 && this.config.VerifyUserDetail)
                {
                    manage.Message = "发表成功,系统审核后将进行展示!";
                }
                else
                {
                    manage.Message = "发表成功";
                }

                return(this.getResult(manage.Error, manage.Message));
            }
        }