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