// Comment related public bool AddTopLevelComment(ReplyTopLevel comment) { using (var cmd = _conn.CreateCommand()) { cmd.CommandText = @"INSERT INTO Comments( ID, Theme, Subforum, Author, Parent, CreatedOn, Content, WasChanged, WasLogicallyDeleted) VALUES(NULL, @theme, @subforum, @author, NULL, @createdon, @content, 0, 0);"; cmd.Parameters.AddWithValue("@theme", comment.ThemeTitle); cmd.Parameters.AddWithValue("@subforum", comment.SubforumName); cmd.Parameters.AddWithValue("@author", comment.AuthorName); cmd.Parameters.AddWithValue("@createdon", comment.CreatedOn.ToString("yyyy-MM-dd")); cmd.Parameters.AddWithValue("@content", comment.Content); return(Execute(cmd)); } }
public ActionResult ReplyTopLevel(string subforum, string title) { if (LoggedUserName == null) { return(View("NotLoggedIn")); } ViewBag.Comment = new ReplyComment(); ViewBag.Comment.SubforumName = subforum; ViewBag.Comment.ThemeTitle = title; if (Request.HttpMethod == "GET") { return(View()); } var comment = new ReplyTopLevel() { AuthorName = LoggedUserName, Content = Request.Params["content"], CreatedOn = DateTime.Now, SubforumName = subforum, ThemeTitle = title }; if (Dao.AddTopLevelComment(comment)) { ViewBag.Title = "Replying Successful"; } else { ViewBag.Title = "Replying Failed"; } return(View("ReplyResult")); }