public ActionResult Delete(int id) { var news = new News(); try { news = db.News.Find(id); db.News.Remove(news); db.SaveChanges(); return Content("ok"); } catch(Exception ex) { log.Error(new LogContent("删除新闻失败", Helpers.HttpHelper.GetIPAddress()), ex); return Content("err"); } }
public ActionResult Show(int id) { var news = new News(); news = db.News.Find(id); return View(news); }
/// <summary> /// 入库 /// </summary> /// <param name="Status"></param> /// <param name="id"></param> /// <returns></returns> public ActionResult SpiderNewsImport(int id) { var news = new SpiderNews(); try { news = opendb.News.Find(id); news.Status = SpiderNewsStatus.已收录; News _news = new News(); _news.Title = news.Title; _news.Content = news.Content; _news.DateTime = DateTime.Now; _news.Category = news.Category; _news.Browses = 0; _news.Area = news.Area; _news.Source = news.Source; _news.Url = news.URL; _news.Summary = news.Summary; db.News.Add(_news); opendb.SaveChanges(); db.SaveChanges(); } catch(Exception ex) { log.Error(new LogContent("修改抓取新闻状态失败", Helpers.HttpHelper.GetIPAddress()), ex); } return Redirect("/Admin/News/SpiderShow/"+id); }