public bool Edit(NewsAction model) { try { var _item = DbContext.News.Find(model.ID); if (_item != null && _item.ID != 0) { if (!model.Avatar.Contains("http")) { _item.Avatar = "http://localhost:44351/" + model.Avatar; } else { _item.Avatar = model.Avatar; } _item.Content = model.Content.Replace("\"/Content/FileUploads/", "\"http://localhost:44351/Content/FileUploads/"); _item.Desc = model.Desc; _item.MetaDesc = model.MetaDesc; _item.MetaKeyword = model.MetaKeyword; _item.MetaTitle = model.MetaTitle; _item.ModifyBy = model.ModifyBy; _item.ModifyDate = DateTime.Now; _item.Status = model.Status; _item.Title = model.Title; return(true); } return(false); } catch (System.Exception) { return(false); } }
public bool Add(NewsAction model) { try { News news = new News(); news.Avatar = "http://localhost:44351/" + model.Avatar; news.Content = model.Content.Replace("\"/Content/FileUploads/", "\"http://localhost:44351/Content/FileUploads/"); news.CreateBy = model.CreateBy; news.CreateDate = DateTime.Now; news.Desc = model.Desc; news.ID = model.ID; news.MetaDesc = model.MetaDesc; news.MetaKeyword = model.MetaKeyword; news.MetaTitle = model.MetaTitle; news.ModifyBy = model.ModifyBy; news.ModifyDate = DateTime.Now; news.Status = model.Status; news.Title = model.Title; news.ViewNumber = 0; DbContext.News.Add(news); return(true); } catch (Exception) { return(false); } }
public NewsAction GetEdit(long id) { try { var _item = DbContext.News.Find(id); if (_item != null && _item.ID != 0) { NewsAction news = new NewsAction(); news.Avatar = _item.Avatar; news.Content = _item.Content; news.CreateBy = _item.CreateBy; news.Desc = _item.Desc; news.ID = _item.ID; news.MetaDesc = _item.MetaDesc; news.MetaKeyword = _item.MetaKeyword; news.MetaTitle = _item.MetaTitle; news.ModifyBy = _item.ModifyBy; news.Status = _item.Status; news.Title = _item.Title; news.ViewNumber = _item.ViewNumber; return(news); } return(new NewsAction()); } catch (System.Exception) { return(new NewsAction()); } }
protected void btnDel_Click(object sender, EventArgs e) { NewsAction newsAction = new NewsAction(); if (newsAction.delNewsType(this.HdnID.Value)) { this.JS.Text = "alert('删除成功!')"; } this.HdnID.Value = ""; this.Dbg_item.DataBind(); }
public ActionResult Edit(NewsAction model) { try { if (ModelState.IsValid) { if (_newsBusiness.Edit(model)) { _newsBusiness.Save(); return(Redirect("/News/List")); } } return(View(model)); } catch (Exception) { return(View(model)); } }
public void InitTypeTree() { TreeNode treeNode = new TreeNode(); treeNode.ID = ""; treeNode.Text = "新闻分类"; treeNode.Target = "frmPage"; treeNode.NavigateUrl = "WebManagerList.aspx?c_xwlxdm=%&c_xwlxmc="; this.trNewsType.Nodes.Add(treeNode); this.trNewsType.NodeID = "c_xwlxdm"; this.trNewsType.NodeText = "c_xwlxmc"; this.trNewsType.ParentId = "c_parentid"; this.trNewsType.Url = "WebManagerList.aspx"; this.trNewsType.Locations = "c_xwlxdm,c_xwlxmc"; NewsAction newsAction = new NewsAction(); this.trNewsType.TreeDataSource = newsAction.getAllNewsType(); this.trNewsType.FillTree(); this.trNewsType.Target = "frmPage"; }
public bool Add(NewsAction model) { return(_news.Add(model)); }
public bool Edit(NewsAction model) { return(_news.Edit(model)); }
protected void btn_Save_Click(object sender, EventArgs e) { DataEntities ent = new DataEntities(); User u = UserAction.opuser; UserGroup g = //UserGroupView.GetModelByID(u.Group.ToS()); (from l in ent.UserGroup where l.ID == u.Group select l).FirstOrDefault(); if (FileUpload1.FileName.IsNullOrEmpty()) { Js.AlertAndGoback("为提高您文章的排名,请选择一张标题图片"); return; } #region 图片 SysSetting ss = BasePage.SystemSetting; HttpPostedFile file = Request.Files["FileUpload1"]; string FileName = file.FileName.GetFileNameFromPath(); //文件名 string ExtName = file.FileName.GetFileExtNameFromPath(); //扩展名 string NewName = @string.GetGuid() + ExtName; //新文件名 if (!ExtName.Replace(".", "").IsInArray(ss.FileExtNameFilter.Split(','))) { Js.AlertAndGoback("不允许上传此类文件"); return; } if (file.ContentLength > ss.MaxPostFileSize) { Js.AlertAndGoback("文件太大"); return; } string Folder = ss.FileDir + "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; //文件目录 string FolderShotCut = Folder + "ShortCut/"; //缩略图目录 string FilePath = Folder + NewName; //文件路径 string FilePath_ShortCut = FolderShotCut + NewName; //缩略图路径 file.SaveAs(Server.MapPath(FilePath), true); ImageHelper.MakeThumbnail(Server.MapPath(FilePath), Server.MapPath(FilePath_ShortCut), 105, 118, "Cut"); FileInfo savedFile = new FileInfo(Server.MapPath(FilePath)); Voodoo.Basement.File f = new Voodoo.Basement.File(); f.FileDirectory = ss.FileDir; f.FileExtName = ExtName; f.FilePath = FilePath; f.FileSize = (savedFile.Length / 1024).ToInt32(); //f.FileType= f.SmallPath = FilePath_ShortCut; f.UpTime = DateTime.Now; ent.AddToFile(f); ent.SaveChanges(); #endregion News n = new News(); n.Author = txt_Author.Text.TrimDbDangerousChar(); n.AutorID = UserAction.opuser.ID; n.ClassID = ddl_Class.SelectedValue.ToInt32(); n.ClickCount = 0; n.Content = txt_Content.Text.TrimDbDangerousChar(); n.Description = txt_Description.Text.TrimDbDangerousChar(); n.DownCount = 0; n.EnableReply = false; n.FTitle = txtFtitle.Text.TrimDbDangerousChar(); n.KeyWords = txt_Keyword.Text.TrimDbDangerousChar(); n.ModelID = 0; n.NavUrl = ""; n.NewsTime = DateTime.Now; n.SetTop = false; n.Source = txt_Source.Text.TrimDbDangerousChar(); n.Title = txt_Title.Text.TrimDbDangerousChar(); n.TitleColor = "000"; n.TitleImage = FilePath;//上传图片 n.ZtID = 0; n.Audit = g.PostAotuAudit; n.FileForder = DateTime.Now.ToString("yyyy-MM-dd"); n.ID = WS.RequestInt("id"); Result r = NewsAction.UserPost(n, UserAction.opuser); if (r.Success) { Js.AlertAndChangUrl(r.Text, "PostList.aspx"); } else { Js.AlertAndGoback(r.Text); } ent.Dispose(); }