/// <summary> /// 新闻复制 /// </summary> /// <param name="ids">新闻id</param> /// <param name="targetIDs">目标栏目id</param> /// <returns></returns> public ActionResult _copyNews(string ids) { #region 访问权限 var user = (Maticsoft.Model.User_Info)ViewBag.curentUser; var curentUser = _iuserService.getUserByID(user.Id); var ManagePermission = curentUser.UserGroup.ManagePermission; List <string> managePermissionstr = new List <string>(ManagePermission.Split(',')); var managePermission = managePermissionstr.Select(x => Convert.ToInt32(x)).ToList(); if (curentUser.UserGroupID != 1) { if (!managePermission.Contains((int)SortEnum.sortClass.newsManage)) { return(new JsonResult() { Data = "error", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } #endregion #region 栏目权限 var sectionPermission = curentUser.UserGroup.SectionPermission; List <string> sectionIDstr = new List <string>(sectionPermission.Split(',')); var sectionIDs = sectionIDstr.Select(x => Convert.ToInt32(x)).ToList(); #endregion try { var targetIds = Request.QueryString["targetIDs"].ToString().Split(','); var leaveIds = ids.Split(','); for (var i = 0; i < leaveIds.Length; i++) { var entity = _inewsService.GetNewsByID(int.Parse(leaveIds[i])); #region 新闻源栏目权限验证 if (!sectionIDs.Contains(entity.ClassID)) { return(new JsonResult() { Data = "error", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } #endregion for (var j = 0; j < targetIds.Length; j++) { #region 目标栏目权限验证 if (!sectionIDs.Contains(int.Parse(targetIds[j]))) { return(new JsonResult() { Data = "error", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } #endregion var newEntity = new HC.Data.Models.News(); #region 新闻构造 newEntity.Author = entity.Author; newEntity.ClickNum = entity.ClickNum; newEntity.CreatTime = entity.CreatTime; newEntity.DeputyTitle = entity.DeputyTitle; newEntity.isDelete = entity.isDelete; newEntity.NewsContent = entity.NewsContent; newEntity.NewsOrder = entity.NewsOrder; newEntity.NewsTitle = entity.NewsTitle; newEntity.PicURL = entity.PicURL; newEntity.ClassID = int.Parse(targetIds[j]); #endregion _inewsService.AddNews(newEntity); #region 附件处理 var newAttchment = entity.Attachments; foreach (var att in newAttchment) { var newAtt = new HC.Data.Models.Attachment(); newAtt.NewsID = newEntity.NewsID; newAtt.AttaType = att.AttaType; newAtt.AttaUrl = att.AttaUrl; newAtt.AttaOrders = att.AttaOrders; newAtt.ClassID = att.ClassID; newAtt.OriginalName = att.OriginalName; newAtt.AttaDescribe = att.AttaDescribe; _iattachmentservice.addAttachment(newAtt); } #endregion } } return(new JsonResult() { Data = "success", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { return(new JsonResult() { Data = "error", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public void UpdateNews(HC.Data.Models.News entity) { this._NewsRepository.Update(entity); }
public void DeleteNews(HC.Data.Models.News entity) { _NewsRepository.Delete(entity); }
public void AddNews(HC.Data.Models.News entity) { _NewsRepository.Insert(entity); }