public static List <PMS.Entities.ProductDTO> GetAllProducts(Boolean pLoadComments = false) { var query = "Select * from dbo.Products Where IsActive = 1;"; using (DBHelper helper = new DBHelper()) { var reader = helper.ExecuteReader(query); List <PMS.Entities.ProductDTO> list = new List <PMS.Entities.ProductDTO>(); while (reader.Read()) { var dto = FillDTO(reader); if (dto != null) { list.Add(dto); } } if (pLoadComments == true) { // var commentsList = CommentDAO.GetAllComments(); var commentsList = CommentDAO.GetTopComments(20); foreach (var prod in list) { List <PMS.Entities.CommentDTO> prodComments = commentsList.Where(c => c.ProductID == prod.ProductID).ToList(); prod.Comments = prodComments; } } return(list); } }
public PartialViewResult ListComments() { var comment = new Comment(); var commentDao = new CommentDAO().GetAllComments(); return(PartialView(commentDao)); }
public PartialViewResult PostComments(int postId) { IEnumerable <ViewCommentsModel> viewComments = new List <ViewCommentsModel>(); viewComments = ViewCommentsModel.GetListComments(CommentDAO.GetComments(postId)); return(PartialView("_Comments", viewComments)); }
public List <CommentVO> GetListOfSubmissionComments(int subID) { CommentDAO dao = new CommentDAO(); List <CommentVO> commentList = dao.GetAllCommentsInASubmission(subID); return(commentList); }
//Quản lý cmt ẩn public ActionResult ListComment(int page = 1) { if (CheckStatusUser()) { return(RedirectToAction("Login")); } if (!CheckAdmin()) { return(RedirectToAction("Index")); } if (page < 1) { page = 1; } var list = new CommentDAO().ListHide(new Pagination(10, page)); ViewBag.Cmts = list.Comments; ViewBag.Numpage = list.PageSize; ViewBag.Page = list.Page; return(View()); }
public ActionResult AddComment(Comment comment) { CommentDAO dao = new CommentDAO(); if (string.IsNullOrEmpty(comment.Name)) { ModelState.AddModelError("Name", "Нет вашего имени!"); } if (string.IsNullOrEmpty(comment.Email)) { ModelState.AddModelError("Email", "Нет вашего email!"); } if (string.IsNullOrEmpty(comment.Body)) { ModelState.AddModelError("Body", "Нет вашего сообщения!"); } if (ModelState.IsValid) { Comment newComment = new Comment() { Name = comment.Name, Body = comment.Body, Email = comment.Email, Date = DateTime.Now.Date }; dao.AddComment(newComment); return(RedirectToAction("AddComment")); } else { var listComment = dao.GetListComment(); return(View(listComment)); } }
public ActionResult AddComment() { CommentDAO dao = new CommentDAO(); var listComment = dao.GetListComment(); return(View(listComment)); }
protected void rptUserPosts_ItemDataBound(object sender, RepeaterItemEventArgs e) { Repeater repeater = (e.Item.FindControl("rptComment") as Repeater); var data = e.Item.DataItem; DAL.UserPost userpost = data as DAL.UserPost; repeater.DataSource = CommentDAO.GetCommentByPost(userpost.Post.Id); repeater.DataBind(); var deltee = e.Item.ItemIndex; var dletepost = userpost.User.Id; Button delte = (e.Item.FindControl("Delete") as Button); HyperLink report = (e.Item.FindControl("mreport") as HyperLink); if (currentUser.Id == dletepost) { delte.Visible = true; } else { delte.Visible = false; } //if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) //{ // var post = e.Item.DataItem as DAL.Post; // repeater.DataSource = CommentDAO.GetCommentByPost(post.Id); // repeater.DataBind(); //} }
public JsonResult Comment(string Message, string idbv) { var session = (DACN.Common.UserLogin)Session[DACN.Common.CommonConstants.USER_SESSION]; TaiKhoan tk = db.TaiKhoans.Find(session.userID); Comment cm = new Comment(); cm.ContentComment = Message; cm.DateComment = DateTime.Now; cm.idBV = Int32.Parse(idbv); if (tk == null) { cm.UserName = null; } else { cm.UserName = tk.Username; } var commentdao = new CommentDAO(); commentdao.Insert(cm); Comment temp = db.Comments.OrderByDescending(p => p.IdComment).FirstOrDefault(); string value = string.Empty; value = JsonConvert.SerializeObject(temp, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(Json(value, JsonRequestBehavior.AllowGet)); }
public void save(Comment comment) { try { string AccessCode = Utility.GetQueryStringValueByKey(Request, "AccessCode"); if (AccessCode != null && AccessCode != string.Empty) { comment.ContextId = Guid.Parse(AccessCode); if (comment.Insert(comment)) { DataSet ds; ds = new CommentDAO().SelectByContext(1, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; Session[Constants.SESSION_COMMENTS] = ds; clear(); // Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Public_Profile.aspx?AccessCode='" + AccessCode + "';}", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "');}", true); } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true); throw ex; } }
//Contructor that sets the connection string to variables for use throughout the controller. public CommentsController() { string connection = ConfigurationManager.ConnectionStrings["dataSource"].ConnectionString; _dataAccess = new CommentDAO(connection); _gameDataAccess = new QuaintDAO(connection); }
public IEnumerable <Comment> Get(int id) { CommentDAO blO = new CommentDAO(); List <Comment> list = blO.getDsBinhLuan(id); return(list); }
public override async Task <Comment> CreateComment(string username, string commentBody, string articleSlug) { var transaction = _context.Database.BeginTransaction(); try { DateTime now = DateTime.Now; ArticleDAO article = await _articleRepository.GetArticleBySlug(articleSlug); int articleId = article.Id; IdentityUser user = await _userManager.FindByNameAsync(username); string authorId = user.Id; CommentDAO commentDao = _commentRepository.CreateComment(commentBody, authorId, articleId); _context.SaveChanges(); Comment comment = await CreateCommentFromDAO(commentDao, username); transaction.Commit(); return(comment); } catch (Exception ex) { transaction.Rollback(); throw ex; } }
public CommentController(IUserService userService) { this.userService = userService; this.userDAO = new UserDAO(); this.product2DAO = new Product2DAO(); this.commentDAO = new CommentDAO(); }
public ActionResult DeleteComment(string idComment) { string status; User user = Session["User"] as User; if (user != null && user.LEVEL.Equals("10")) { if (CommentDAO.DeleteCommentByID(int.Parse(idComment))) { status = "success"; return(new JsonResult { Data = new { status = status } }); } else { status = "fail"; return(new JsonResult { Data = new { status = status } }); } } else { return(RedirectToAction("Index", "Home", new { area = "" })); } }
protected void rptUserPosts_ItemCommand(object source, RepeaterCommandEventArgs e) { Repeater repeater = (e.Item.FindControl("rptComment") as Repeater); if (e.CommandName == "Comment") { TextBox comment = (e.Item.FindControl("hello") as TextBox); var comt = comment.Text; var newComment = new BLL.Comment(); newComment.UserId = currentUser.Id; newComment.PostId = Convert.ToInt32(e.CommandArgument); newComment.comment_date = DateTime.Now; newComment.comment_text = comment.Text; CommentDAO.AddComment(newComment); comment.Text = String.Empty; repeater.DataSource = CommentDAO.GetCommentByPost(Convert.ToInt32(e.CommandArgument)); repeater.DataBind(); } if (e.CommandName == "Report") { RadioButtonList report = (e.Item.FindControl("RadioButtonList1") as RadioButtonList); var userpostindex = e.Item.ItemIndex; var rpt = report.SelectedValue; List <UserPost> userposts = new List <UserPost>(); UserPost selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex]; var newReport = new BLL.ReportedPost(); newReport.postId = selecteduserpost.Post.Id; newReport.reason = rpt; newReport.dateCreated = DateTime.Now; newReport.reporterUserId = currentUser.Id; ReportedPostDAO.AddReport(newReport); } if (e.CommandName == "Delete") { var deleteId = Convert.ToInt32(e.CommandArgument); var userpostindex = e.Item.ItemIndex; UserPost selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex]; if (currentUser.Id == selecteduserpost.User.Id) { CommentDAO.DeleteCommentByPostId(selecteduserpost.Post.Id); ReportedPostDAO.DeleteReportedPostByPostId(selecteduserpost.Post.Id); PostDAO.DeletePost(deleteId); refreshGv(); UserCircleDAO.ChangeUserCirclePoints( userId: currentUser.Id, circleName: selecteduserpost.Post.CircleId, points: -30, source: "removing a post", addNotification: true ); } } }
public void BeforeEachTest() { //create DAOs items = new ItemDAO(); users = new UserDAO(); comments = new CommentDAO(); categories = new CategoryDAO(); }
public ActionResult UnableFromPost(int commentId, int postId) { Comment comment = CommentDAO.FindId(commentId); comment.Status = 0; CommentDAO.EditComment(comment); return(RedirectToAction("Detail", "Post", new { id = postId })); }
public int CheckIfVoted(int comID, int userID) { int voted; CommentDAO dao = new CommentDAO(); voted = dao.CheckIfVoted(userID, comID); return(voted); }
public List <CommentVO> GetListOfCommentsByUserID(int size, int userID) { CommentDAO dao = new CommentDAO(); List <CommentVO> commentList = dao.GetAllUsersComments(userID); TruncateList(commentList, size); return(commentList); }
public void SubmitVote(int comID, int uID, int vote) { UserManagementBO userBO = new UserManagementBO(); CommentDAO dao = new CommentDAO(); dao.SubmitVote(uID, comID, vote); userBO.ChangeRating(uID, vote); }
public ActionResult Detail(int id) { Post post = PostDAO.FindId(id); List <Comment> comments = CommentDAO.GetComments(id); ViewBag.Post = post; ViewBag.Comments = comments; return(View()); }
public ActionResult DisableFromPanel(int commentId) { Comment comment = CommentDAO.FindId(commentId); comment.Status = 1; CommentDAO.EditComment(comment); return(RedirectToAction("UserPanel", "User")); }
public void LoadComments(Guid AccessCode) { DataSet ds; ds = new CommentDAO().SelectByContext(2, AccessCode); ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; DataListStudentComments.DataSource = ds.Tables[0]; DataListStudentComments.DataBind(); }
public ViewPostModel(Post post) { PostId = post.PostId; PostTitle = post.PostTitle; PostBody = post.PostBody; PostDate = post.PostDate; AuthorId = post.AuthorId; Author = UserDAO.GetUsername(post.AuthorId); Comments = ViewCommentsModel.GetListComments(CommentDAO.GetComments(post.PostId)); }
//public void LoadComments(Guid AccessCode) //{ // DataSet ds; // ds = new CommentDAO().SelectByContext(1, AccessCode); // ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; // DataListStudentComments.DataSource = ds.Tables[0]; // DataListStudentComments.DataBind(); //} public void LoadComments() { DataSet ds = null; ds = new CommentDAO().SelectByContext(1, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["CommentId"] }; DataListStudentComments.DataSource = ds.Tables[0]; DataListStudentComments.DataBind(); }
public static List <CommentDto> GetAllComment(int productId) { List <CommentDto> allComment = new List <CommentDto>(); IList <Comments> IComments = CommentDAO.getAllCommentByProduct(productId); if (IComments != null) { allComment = Common.ConvertToCommentDto(IComments.ToList()); } return(allComment); }
public bool DeleteComment(CommentDto commentDto) { try { CommentDAO.Execute(Common.ConvertToComments(commentDto), Entity.COMMENT, ExecuteType.REMOVE); return(true); } catch (Exception e) { return(false); } }
private async Task <Comment> CreateCommentFromDAO(CommentDAO commentDao, string authedUsername = null) { IdentityUser author = await _userManager.FindByIdAsync(commentDao.AuthorId); return(new Comment { Author = await _profileService.GetProfile(author.UserName, authedUsername), Body = commentDao.Body, Id = commentDao.Id, CreatedAt = commentDao.CreatedAt, UpdatedAt = commentDao.UpdatedAt }); }
public string ApiDeleteCommentById(int id) { CommentDAO commentDAO = new CommentDAO(); if (commentDAO.DeleteCommentById(id, out string message)) { return("Comentario excluido com sucesso! "); } else { return("Erro ao deletar o comentario " + message); } }
/// <summary> Create test data for our domain model. /// /// </summary> /// <throws> Exception </throws> protected internal virtual void InitData() { CreateDatabase(); // Prepare DAOS CategoryDAO catDAO = new CategoryDAO(); UserDAO userDAO = new UserDAO(); ItemDAO itemDAO = new ItemDAO(); CommentDAO commentDAO = new CommentDAO(); // Categories cars = new Category("Cars"); carsLuxury = new Category("Luxury Cars"); cars.AddChildCategory(carsLuxury); carsSUV = new Category("SUVs"); cars.AddChildCategory(carsSUV); catDAO.MakePersistent(cars); // Users u1 = new User("Christian", "Bauer", "turin", "abc123", "*****@*****.**"); u1.HomeAddress = new Address("Foo", "12345", "Bar"); u1.IsAdmin = true; u2 = new User("Gavin", "King", "gavin", "abc123", "*****@*****.**"); u2.HomeAddress = new Address("Foo", "12345", "Bar"); u3 = new User("Max", "Andersen", "max", "abc123", "*****@*****.**"); u3.HomeAddress = new Address("Foo", "12345", "Bar"); userDAO.MakePersistent(u1); userDAO.MakePersistent(u2); userDAO.MakePersistent(u3); // BillingDetails BillingDetails ccOne = new CreditCard( "Christian Bauer", u1, "1234567890", CreditCardType.MasterCard, "10", "2005"); BillingDetails accOne = new BankAccount( "Christian Bauer", u1, "234234234234", "FooBar Rich Bank", "foobar123foobaz"); u1.AddBillingDetails(ccOne); u1.AddBillingDetails(accOne); // Items DateTime tempAux = DateTime.Now; DateTime tempAux2 = DateTime.Now.AddDays(3);// inThreeDays auctionOne = new Item("Item One", "An item in the carsLuxury category.", u2, new MonetaryAmount(1.99, "USD"), new MonetaryAmount(50.33, "USD"), tempAux, tempAux2); auctionOne.SetPendingForApproval(); auctionOne.Approve(u1); itemDAO.MakePersistent(auctionOne); new CategorizedItem(u1.Username, carsLuxury, auctionOne); DateTime tempAux3 = DateTime.Now; DateTime tempAux4 = DateTime.Now.AddDays(5); // inFiveDays auctionTwo = new Item("Item Two", "Another item in the carsLuxury category.", u2, new MonetaryAmount(2.22, "USD"), new MonetaryAmount(100.88, "USD"), tempAux3, tempAux4); itemDAO.MakePersistent(auctionTwo); new CategorizedItem(u1.Username, carsLuxury, auctionTwo); DateTime tempAux5 = DateTime.Now; DateTime tempAux6 = DateTime.Now.AddDays(3);// inThreeDays auctionThree = new Item("Item Three", "Don't drive SUVs.", u2, new MonetaryAmount(3.11, "USD"), new MonetaryAmount(300.55, "USD"), tempAux5, tempAux6); itemDAO.MakePersistent(auctionThree); new CategorizedItem(u1.Username, carsSUV, auctionThree); DateTime tempAux7 = DateTime.Now; DateTime tempAux8 = DateTime.Now.AddDays(7);// nextWeek auctionFour = new Item("Item Four", "Really, not even luxury SUVs.", u1, new MonetaryAmount(4.55, "USD"), new MonetaryAmount(40.99, "USD"), tempAux7, tempAux8); itemDAO.MakePersistent(auctionFour); new CategorizedItem(u1.Username, carsLuxury, auctionFour); new CategorizedItem(u1.Username, carsSUV, auctionFour); // Bids Model.Bid bidOne1 = new Model.Bid(new MonetaryAmount(12.12, "USD"), auctionOne, u3); Model.Bid bidOne2 = new Model.Bid(new MonetaryAmount(13.13, "USD"), auctionOne, u1); Model.Bid bidOne3 = new Model.Bid(new MonetaryAmount(14.14, "USD"), auctionOne, u3); auctionOne.AddBid(bidOne1); auctionOne.AddBid(bidOne2); auctionOne.AddBid(bidOne3); // Successful Bid auctionOne.SuccessfulBid = bidOne3; // Comments Comment commentOne = new Comment(Rating.Excellent, "This is Excellent.", u3, auctionOne); Comment commentTwo = new Comment(Rating.Low, "This is very Low.", u1, auctionThree); commentDAO.MakePersistent(commentOne); commentDAO.MakePersistent(commentTwo); NHibernateHelper.CommitTransaction(); NHibernateHelper.CloseSession(); }