예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(Request.QueryString["id"].ToString());
                news = new News();
                news = NewsHelper.GetNews(id);
            }
            catch 
            {
            }

        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //获取要查看的新闻ID
            int id = Convert.ToInt32(RouteData.Values["id"]);

            Msg = NewsHelper.GetNews(id);

            //bshare需要抓取的两个内容
            Page.Header.Title = Msg.Title;
            Page.Header.Description = Msg.Title;

            //更新统计数据
            using (var db = new SCenterEntities())
            {
                Msg.ClickCount += 1;
                db.Attach(Msg);
                db.ObjectStateManager.ChangeObjectState(Msg, System.Data.EntityState.Modified);
                db.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
            }
        }
예제 #3
0
 /// <summary>
 /// 用于向 News EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToNews(News news)
 {
     base.AddObject("News", news);
 }
예제 #4
0
 /// <summary>
 /// 创建新的 News 对象。
 /// </summary>
 /// <param name="nid">Nid 属性的初始值。</param>
 /// <param name="title">Title 属性的初始值。</param>
 /// <param name="content">Content 属性的初始值。</param>
 /// <param name="postTime">PostTime 属性的初始值。</param>
 /// <param name="isPicNews">IsPicNews 属性的初始值。</param>
 /// <param name="isLoopPicNews">IsLoopPicNews 属性的初始值。</param>
 public static News CreateNews(global::System.Int64 nid, global::System.String title, global::System.String content, global::System.DateTime postTime, global::System.Boolean isPicNews, global::System.Boolean isLoopPicNews)
 {
     News news = new News();
     news.Nid = nid;
     news.Title = title;
     news.Content = content;
     news.PostTime = postTime;
     news.IsPicNews = isPicNews;
     news.IsLoopPicNews = isLoopPicNews;
     return news;
 }