public virtual OperationResult Create(PlateNewsInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { PlateNews entity = new PlateNews(); DESwap.PlateNewsDTE(info, entity); PlateNewsRpt.Insert(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Create(ArticleAnnexInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { ArticleAnnex entity = new ArticleAnnex(); DESwap.ArticleAnnexDTE(info, entity); ArticleAnnexRpt.Insert(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Create(FriendLinkInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { FriendLink entity = new FriendLink(); DESwap.FriendLinkDTE(info, entity); FriendLinkRpt.Insert(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public override OperationResult Create(AdviceInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { Advice entity = new Advice(); DESwap.AdviceDTE(info, entity); /*需要设默认值*/ entity.HandleTime = DateTime.Now; AdviceRpt.Insert(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Create(IEnumerable<ArticleAnnexInfo> infoList) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); List<ArticleAnnex> eList = new List<ArticleAnnex>(); infoList.ForEach(x => { ArticleAnnex entity = new ArticleAnnex(); DESwap. ArticleAnnexDTE(x, entity); eList.Add(entity); }); using (var DbContext = new CmsDbContext()) { ArticleAnnexRpt.Insert(DbContext, eList); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Create(IEnumerable<FriendLinkInfo> infoList) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); List<FriendLink> eList = new List<FriendLink>(); infoList.ForEach(x => { FriendLink entity = new FriendLink(); DESwap. FriendLinkDTE(x, entity); eList.Add(entity); }); using (var DbContext = new CmsDbContext()) { FriendLinkRpt.Insert(DbContext, eList); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Remove(IEnumerable<string> keyList) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); List<ArticleAnnex> eList = new List<ArticleAnnex>(); using (var DbContext = new CmsDbContext()) { keyList.ForEach(x => { ArticleAnnex entity = ArticleAnnexRpt.Get(DbContext, x); eList.Add(entity); }); ArticleAnnexRpt.Delete(DbContext, eList); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Remove(string key) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { ArticleAnnex entity = ArticleAnnexRpt.Get(DbContext, key); ArticleAnnexRpt.Delete(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Modify(IEnumerable<PlateNewsInfo> infoList) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); List<PlateNews> eList = new List<PlateNews>(); infoList.ForEach(x => { PlateNews entity = new PlateNews(); DESwap. PlateNewsDTE(x, entity); eList.Add(entity); }); using (var DbContext = new CmsDbContext()) { PlateNewsRpt.Update(DbContext, eList); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public override OperationResult Create(ArticleInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { /*******保存资讯正文摘要*******/ info.AuditTime = DateTime.Now; info.AuditState = (int)sct.dto.cms.EnumSet.ArticleAuditState.Edit; Article entity = new Article(); DESwap.ArticleDTE(info, entity); ArticleRpt.Insert(DbContext, entity); if (info.ArticleType == (int)sct.dto.cms.EnumSet.ArticleType.Article) { /*******保存正文*******/ if (info.ArticleDetail == null) { info.ArticleDetail = new ArticleDetailInfo(); } info.ArticleDetail.Id = System.Guid.NewGuid().ToString(); info.ArticleDetail.ArticleId = info.Id; ArticleDetail detail = new ArticleDetail(); DESwap.ArticleDetailDTE(info.ArticleDetail, detail); ArticleDetailRpt.Insert(DbContext, detail); } else if (info.ArticleType == (int)sct.dto.cms.EnumSet.ArticleType.Picture) { /*******保存图片*******/ List<ArticleImage> imagelist = new List<ArticleImage>(); foreach (var imageinfo in info.ArticleImageList) { if (string.IsNullOrEmpty(imageinfo.Id)) { imageinfo.Id = System.Guid.NewGuid().ToString(); imageinfo.ArticleId = info.Id; ArticleImage image = new ArticleImage(); DESwap.ArticleImageDTE(imageinfo, image); imagelist.Add(image); } } ArticleImageRpt.Insert(DbContext, imagelist); } else if (info.ArticleType == (int)sct.dto.cms.EnumSet.ArticleType.Video) { /*******保存视频*******/ if (info.ArticleVideo == null) { info.ArticleVideo = new ArticleVideoInfo(); } info.ArticleVideo.Id = System.Guid.NewGuid().ToString(); info.ArticleVideo.ArticleId = info.Id; ArticleVideo video = new ArticleVideo(); DESwap.ArticleVideoDTE(info.ArticleVideo, video); ArticleVideoRpt.Insert(DbContext, video); } /*异常数据未处理*/ DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public override OperationResult Modify(ArticleInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { /*******保存资讯正文摘要*******/ Article article = ArticleRpt.Get(DbContext, info.Id); DESwap.ArticleDTE(info, article); ArticleRpt.Update(DbContext, article); if (info.ArticleType == (int)sct.dto.cms.EnumSet.ArticleType.Article) { /*******保存正文*******/ ArticleDetail detail = ArticleDetailRpt.Get(DbContext, info.ArticleDetail.Id); DESwap.ArticleDetailDTE(info.ArticleDetail, detail); ArticleDetailRpt.Update(DbContext, detail); } else if (info.ArticleType == (int)sct.dto.cms.EnumSet.ArticleType.Picture) { /*****新增列表*********/ List<ArticleImage> imageinsertlist = new List<ArticleImage>(); /*****例改列表*********/ List<ArticleImage> imageupdatelist = new List<ArticleImage>(); /*****删除列表*********/ List<ArticleImage> imagedeletelist = new List<ArticleImage>(); var imageexistlist = (from i in DbContext.ArticleImage where i.ArticleId.Equals(article.Id) select i).ToList(); /*************新增或修改******************/ foreach (var imageinfo in info.ArticleImageList) { if (string.IsNullOrEmpty(imageinfo.Id)) { /*************新增************************/ imageinfo.Id = System.Guid.NewGuid().ToString(); imageinfo.ArticleId = info.Id; ArticleImage image = new ArticleImage(); DESwap.ArticleImageDTE(imageinfo, image); imageinsertlist.Add(image); } else { /****************修改********************/ var image = imageexistlist.Where(x => x.Id.Equals(imageinfo.Id)).FirstOrDefault(); if (image != null) { //ArticleImage image = ArticleImageRpt.Get(DbContext, imageinfo.Id); DESwap.ArticleImageDTE(imageinfo, image); imageupdatelist.Add(image); } else { imageinfo.Id = System.Guid.NewGuid().ToString(); imageinfo.ArticleId = info.Id; image = new ArticleImage(); DESwap.ArticleImageDTE(imageinfo, image); imageinsertlist.Add(image); } } } /*************删除******************/ foreach (var imageexist in imageexistlist) { var image = info.ArticleImageList.Where(x => x.Id.Equals(imageexist.Id)).FirstOrDefault(); if (image == null) { imagedeletelist.Add(imageexist); } } ArticleImageRpt.Insert(DbContext, imageinsertlist); ArticleImageRpt.Update(DbContext, imageupdatelist); ArticleImageRpt.Delete(DbContext, imagedeletelist); } else if (info.ArticleType == (int)sct.dto.cms.EnumSet.ArticleType.Video) { /*******保存视频*******/ ArticleVideo video = ArticleVideoRpt.Get(DbContext, info.ArticleVideo.Id); DESwap.ArticleVideoDTE(info.ArticleVideo, video); ArticleVideoRpt.Update(DbContext, video); } /*异常数据未处理*/ DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public virtual OperationResult Modify(ArticleImageInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { ArticleImage entity = ArticleImageRpt.Get(DbContext, info.Id); DESwap.ArticleImageDTE(info, entity); ArticleImageRpt.Update(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }