示例#1
0
 public void DeleteComment( Comment comment )
 {
     db.Comments.DeleteOnSubmit( comment );
 }
示例#2
0
        public ActionResult Details( int id )
        {
            var news = newsRepository.GetNews( id );
            var comments = newsRepository.FindAllComments( news.id );
            var comment = new Comment();

            var newsComments = new NewsComments() {News = news, Comments = comments, Comment = comment};
            var newsId = news.id.ToString();
            ViewData["Tags"] = newsRepository.GetTags( news.id );

            // Increase page views count

            var cookie = Request.Cookies["views"];
            if (cookie == null)
            {
                var newcookie = new HttpCookie( "views" ) {Value = newsId, Expires = DateTime.UtcNow.AddYears( 1 )};
                Response.Cookies.Add( newcookie );
                newsRepository.IncreaseViewsCount( news.id );
            }
            else
            {
                var cookieValues = cookie.Value;
                if (!cookieValues.Contains( newsId ))
                {
                    cookie.Value += "|" + newsId;
                    Response.Cookies.Set( cookie );
                    newsRepository.IncreaseViewsCount( news.id );
                }
            }

            newsRepository.IncreaseHitsCount( news.id );

            if (news == null)
                return View( "NotFound" );

            return View( newsComments );
        }
示例#3
0
 public void AddComment( Comment comment )
 {
     db.Comments.InsertOnSubmit( comment );
 }
示例#4
0
 public ActionResult CreateComment()
 {
     var comment = new Comment();
     return View( comment );
 }
示例#5
0
        public ActionResult CreateComment(FormCollection collection )
        {
            var comment = new Comment();
            try
            {
                // TODO: Add insert logic here
                UpdateModel( comment );

                Int64 newsId = 0;
                Int64.TryParse( Request.Form["newsId"], out newsId );
                comment.parent_id = newsId;
                comment.created_at = DateTime.UtcNow;
                comment.ip_address = System.Web.HttpContext.Current.Request.UserHostAddress;
                comment.author_id = newsRepository.GetAuthorId( User.Identity.Name );
                comment.voted_for = 0;
                comment.voted_against = 0;

                newsRepository.AddComment( comment );
                newsRepository.Save();

                return RedirectToAction( "Details", "News", new { id = newsId } );
            }
            catch
            {
                return View( "NotFound" );
            }
        }
示例#6
0
		private void detach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.News = null;
		}
示例#7
0
		private void attach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.News = this;
		}
示例#8
0
 partial void DeleteComment(Comment instance);
示例#9
0
 partial void UpdateComment(Comment instance);
示例#10
0
 partial void InsertComment(Comment instance);