public void OnGet() { var connection = Connection.Open(); try { Id = int.Parse(HttpContext.Request.Query["open"]); } catch { ReturnWithError(); return; } var reader = connection.GetDataFromDb($@"SELECT * FROM FORUM WHERE discussion_id = '{Id}'"); if (reader.Read()) { Discussion = ForumDAO.MadeNewDiscussionObject(reader, connection); } reader.Close(); if (Discussion == null || Discussion.Name == null || Discussion.Name.Length < 1) { ReturnWithError(); return; } reader = CommentsDAO.GetAllComments(Id, connection); Comments = new List <Comments>(); while (reader.Read()) { Comments.Add(CommentsDAO.MadeNewCommentObject(reader, connection)); } connection.Close(); }
public static bool AddReplyComment(Comment cmt) { CommentsDAO dao = new CommentsDAO(); bool add = dao.AddReplyCmt(cmt); return(add); }
// GET: Store/Comment public ActionResult Index(string searchString, int page = 1, int pageSize = 4) { if (Session["UserName"] == null) { return(RedirectToAction("Login", "AccountAdmin")); } var dao = new CommentsDAO(); var model = dao.ListAllPaging(searchString, page, pageSize); ViewBag.SearchString = searchString; return(View("~/Areas/Store/Views/Comment/Index.cshtml", model)); }
private object GetDataComments(int bookID) { List <Comment> commentList = CommentsDAO.GetComments(bookID); object jsonData = (from d in commentList select new { comment_id = d.CommentID, username = CommentsDAO.getUsername(d.UserID), picture = CommentsDAO.getPicture(d.UserID), content = d.Content, date = string.Format("{0} {1}", CommonConstant.GetWeekOfDate(d.CreatedDate, "dd/MM/yyyy"), d.CreatedDate.ToString("HH:mm")), }).ToList(); return(jsonData); }
public ActionResult Delete(int id) { var dao = new CommentsDAO(); var result = dao.Delete(id); if (result) { return(RedirectToAction("Index", "Comment")); } else { ModelState.AddModelError("", "Xóa không thành công"); } return(View("Index")); }
public JsonResult DeleteByID(int id) { var result = new CommentsDAO().Delete(id); if (result) { return(Json(new { status = true })); } else { return(Json(new { status = false })); } }