public IHttpActionResult PutNews(int id, NewsInfo nw) { ctx.Entry(nw).State = EntityState.Modified; ctx.SaveChanges(); return(Ok(nw)); }
public ActionResult ModifyNewsConfirm() { NewsInfo news = new NewsInfo(); news.news_id = int.Parse(Request.Form["id"]); news.news_title = Request.Form["title"]; news.news_author = Request.Form["author"]; news.news_source = Request.Form["from"]; news.news_abstract = Request.Form["abstract"]; news.new_release_time = DateTime.Now; String text = Request.Form["text"]; text = text.Replace("#lt;", "<"); text = text.Replace("#gt;", ">"); news.news_content = text; int categoryId = int.Parse(Request.Form["classify"]); news.newsCategory_id = categoryId; if (ModelState.IsValid) { newsContext.Entry(news).State = EntityState.Modified; newsContext.SaveChanges(); } return(Content("修改成功")); }