public ActionResult Modify(int ID, [Bind(Include = "ID,UserID,MovieID,Releasetime,Title,Content,Auditstatus")] Article article, HttpPostedFileBase banner) { if (banner != null) { var bannerName = Path.Combine(Request.MapPath("/ArticleImg"), article.ID + ".jpg"); if (System.IO.File.Exists(bannerName)) { System.IO.File.Delete(bannerName); } banner.SaveAs(bannerName); } if (ModelState.IsValid) { var _resp = articleManage.Update(article); if (_resp.Code == 1) { return(View("Prompt", new Prompt() { Title = "修改文章数据成功", Message = "您已成功的修改了文章【" + _resp.Data.Title + "】", Buttons = new List <string>() { "<a href=\"" + Url.Action("Index", "Article") + "\" class=\"btn btn-default\">返回电影管理</a>", "<a href=\"" + Url.Action("Add", "Article") + "\" class=\"btn btn-default\">添加电影</a>" } } )); } else { ModelState.AddModelError("", _resp.Message); } } return(View(article)); }
void btnSave_Click(object sender, EventArgs e) { int _selectCategoryId = Convert.ToInt32(this.ddlcategoryList.SelectedValue); if (_selectCategoryId == 0) { this.ltErrorMsg.Text = "请选择所属分类"; return; } articleInfo = new ArticleInfo(); articleInfo.ArticleId = articleId; articleInfo.CategoryId = _selectCategoryId; articleInfo.Title = txtTitle.Text; articleInfo.Content = txtContent.Text; articleInfo.GUID = Guid.NewGuid().ToString(); articleInfo.PublishDate = Convert.ToDateTime(string.Format("{0} {1}", this.PublishDate.SelectedDate.ToString("yyyy-MM-dd"), DateTime.Now.ToString("hh:mm:ss"))); articleInfo.LinkUrl = this.txtLinkUrl.Text; articleInfo.Url = string.Format("{1}news/html/{0}.aspx", articleInfo.GUID, ResolveUrl("~")); articleInfo.ImageUrl = this.txtImageUrl.Text; articleInfo.Introduction = this.txtIntroduction.Text; if (!string.IsNullOrEmpty(articleInfo.LinkUrl)) { articleInfo.Url = this.articleInfo.LinkUrl; } ArticleManage.Update(articleInfo); string js = string.Format("alert('保存成功!');window.location.href='articlelist.aspx?categoryId={0}';", _selectCategoryId); Page.ClientScript.RegisterStartupScript(this.GetType(), "SaveSuccess", js, true); }
/// <summary> /// 添加或编辑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Create(ArticleInfo model) { if (model.Id > 0) { //Update ArticleManage.Update(model); } else { int i = ArticleManage.Insert(model); model.Id = i; } return(model.Id); }
public static ArticleInfo Create(ArticleInfo model) { if (model.Id == 0) { //Insert int id = ArticleManage.Insert(model); model.Id = id; } else { ArticleManage.Update(model); } //插入ArticleTags表 ArticleManage.InsertArticleTagData(model.Id, model.Tags); return(model); }
/// <summary> /// 添加或编辑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Create(ArticleInfo model) { //处理一下关键词 if (!string.IsNullOrEmpty(model.Keywords)) { model.Keywords = Regex.Replace(model.Keywords, @"(\s+|,)", ","); } if (model.Id > 0) { //Update ArticleManage.Update(model); } else { int i = ArticleManage.Insert(model); model.Id = i; } return(model.Id); }
private const int CACHETIMEOUT = 0;//缓存30分钟 #region == Edit OR Add == /// <summary> /// 添加或编辑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Create(ArticleInfo model) { if (model.Id > 0) { //Update ArticleManage.Update(model); } else { int i = ArticleManage.Insert(model); model.Id = i; } //Insert ArticleTag string[] tags = model.Tags.Split(new char[] { ',' }); if (tags.Length > 0) { ArticleManage.InsertTags(model.Id, tags); } return(model.Id); }