Exemplo n.º 1
0
 public void DeleteComment( Comment comment )
 {
     db.Comments.DeleteOnSubmit( comment );
 }
Exemplo n.º 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 );
        }
Exemplo n.º 3
0
 public void AddComment( Comment comment )
 {
     db.Comments.InsertOnSubmit( comment );
 }
Exemplo n.º 4
0
 public ActionResult CreateComment()
 {
     var comment = new Comment();
     return View( comment );
 }
Exemplo n.º 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" );
            }
        }
Exemplo n.º 6
0
		private void detach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.News = null;
		}
Exemplo n.º 7
0
		private void attach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.News = this;
		}
Exemplo n.º 8
0
 partial void DeleteComment(Comment instance);
Exemplo n.º 9
0
 partial void UpdateComment(Comment instance);
Exemplo n.º 10
0
 partial void InsertComment(Comment instance);