/// <summary> /// 更新内容详情 /// </summary> public void updateDetailContent(Entity.DetailContentInfo info) { if (info.ContentId <= 0) { info.InDate = Config.SiteConfig.getLocalTime(); this.dbContext.DetailContent.Add(info); } else { this.dbContext.Entry <Entity.DetailContentInfo>(info).State = System.Data.Entity.EntityState.Modified; } this.dbContext.SaveChanges(); }
/// <summary> /// 更新内容详情 /// </summary> /// <param name="list"></param> public void updateDetailContent(List <Entity.DetailContentInfo> list, int detailid, int itemid, string channelcode) { var oldlist = this.getDetailContentList(detailid); foreach (var info in list) { Entity.DetailContentInfo oldInfo = null; if (oldlist.Count > 0) { oldInfo = oldlist[0]; oldlist.Remove(oldInfo); } else { oldInfo = new Entity.DetailContentInfo(); oldInfo.InDate = Config.SiteConfig.getLocalTime(); } oldInfo.DetailId = detailid; oldInfo.Content = info.Content; oldInfo.OrderNo = info.OrderNo; oldInfo.Title = info.Title; oldInfo.ItemId = itemid; oldInfo.ChannelCode = channelcode; if (oldInfo.ContentId <= 0) { this.dbContext.DetailContent.Add(oldInfo); } } if (oldlist.Count > 0) { this.dbContext.DetailContent.RemoveRange(oldlist); } this.dbContext.SaveChanges(); }
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)); } }