public ActionResult Detail(int id) { _productID = id; ProductDao pDao = new ProductDao(); Product p = pDao.FindProductByICode(id); ProductImageDao iDao = new ProductImageDao(); IQueryable <ProductImage> listImage = iDao.FindImage(id); ViewBag.Image = listImage; IQueryable <CF_Products_Categories> listCF_P_Cat = pDao.Find_CF_Product_Categories(id); ViewBag.CF_Category = listCF_P_Cat; ProductDao pdDao = new ProductDao(); List <ViewProduct> listImage2 = pdDao.ListViewProduct(10); ViewBag.ViewNewsProduct2 = listImage2; CategoryDao cDao = new CategoryDao(); IQueryable <Category> listCates = cDao.ListCategory(); ViewBag.Category = listCates; CommentDao cmDao = new CommentDao(); List <ViewComment> listComment = cmDao.ListComment(id); ViewBag.Comment = listComment; return(View(p)); }
public void UpdateTagComment(string userLogin, long commentId, List <String> tags) { Comment comment = CommentDao.Find(commentId); comment.Tags.Clear(); foreach (var tag in tags) { String tagLower = tag.ToLower(); if (!TagDao.Exists(tagLower)) { Tag newTag = new Tag { tagName = tagLower }; newTag.Comment.Add(comment); TagDao.Create(newTag); comment.Tags.Add(newTag); } else { Tag tagInDatabase = TagDao.Find(tagLower); comment.Tags.Add(tagInDatabase); tagInDatabase.Comment.Add(comment); } } }
public ActionResult FeedBackIndex(string searchString, int page = 1, int pageSize = 5) { var dao = new CommentDao(); var model = dao.ListAllPaging(searchString, page, pageSize); return(View(model)); }
public JsonResult Searching() { if (Session[CommonConstants.USER_SESSION] != null) { try { var data = Request.Form; var comments = new CommentDao().SearchComment(data["search"]); return(Json(new { status = true, data = comments }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Comment(string content, int id) { var product = new ProductDao().ViewDetail(id); var session = (UserLogin)Session[OnlineShop.Common.CommonConstant.USER_SESSION]; var feedback = new FeedBack(); if (session != null) { feedback.ProductID = product.ID; feedback.Content = content; feedback.Customer = session.Username; feedback.CreatedDate = DateTime.Now; feedback.Status = false; } var result = new CommentDao().Insert(feedback); if (result > 0) { return(Json(new { status = true })); } else { return(Json(new { status = false })); } }
public ServiceFacade() { this._userDao = new UserDao(); this._movieDao = new MovieDao(); this._commentDao = new CommentDao(); this._rateDao = new RateDao(); }
public void OnGet(string courseId) { var id = int.Parse(courseId); var courseDao = new CourseDao(); Course = courseDao.GetById(id); var commentDao = new CommentDao(); Comments = commentDao.GetByCourseId(id); var usersId = HttpContext.Session.GetInt32("users_id"); if (usersId == null && HttpContext.Request.Cookies.ContainsKey("users_id")) { usersId = int.Parse(HttpContext.Request.Cookies["users_id"]); var usersName = HttpContext.Request.Cookies["users_name"]; HttpContext.Session.SetInt32("users_id", (int)usersId); HttpContext.Session.SetString("users_name", usersName); } UserIsAuthorized = usersId != null; if (UserIsAuthorized) { var usersCourses = new UsersDao().GetCourses((int)usersId); UserHasThisCourse = usersCourses.Select(c => c.Id).Contains(id); } }
public ActionResult Edit(int commentId) { CommentDao cDao = new CommentDao(); Comment comment = cDao.GetById(commentId); return(View(comment)); }
public ActionResult Detail(int articleId) { ArticleDao aDao = new ArticleDao(); CommentDao cDao = new CommentDao(); Article article = aDao.GetById(articleId); ViewBag.CommentsCount = cDao.GetByArticleId(article).Count.ToString(); User user = Membership.GetUser(User.Identity.Name) as User; if (user != null && User.Identity.IsAuthenticated) { if (user.Id == article.AuthorId) { ViewBag.canEdit = true; } else { if (User.IsInRole("Admin")) { ViewBag.canEdit = true; } else { ViewBag.canEdit = false; } } } else { ViewBag.canEdit = false; } return(View(article)); }
/// <exception cref="InstanceNotFoundException"/> public void UpdateComment(long commentId, string commentBody) { Comment comment = CommentDao.Find(commentId); comment.comment1 = commentBody; CommentDao.Update(comment); }
public ActionResult Detail(int Id) { var product = new ProductDao().ViewDetail(Id); var commentDao = new CommentDao(); ViewBag.listfeedback = commentDao.ListFeedBack(); return(View(product)); }
public AddOrderProxy() { OrderModel = new OrderDao(context); CustomerModel = new CustomerDao(context); GoodsModel = new GoodsDao(context); GoodsRowModel = new GoodsRowDao(context); OrderStatusModel = new OrderStatusDao(context); CommentModel = new CommentDao(context); }
public DTOComment getComment(long commentId) { Comment comment; comment = CommentDao.Find(commentId); //////////FALTA DEVOLVER LOS TAGS DEL COMENTARIO en el DTO return(new DTOComment(commentId, comment.UserProfile.loginName, comment.eventId, comment.comment_description, comment.publishDate, null)); }
public JsonResult ChangeStatus(int id) { var result = new CommentDao().ChangeStatus(id); return(Json(new { status = result })); }
public ActionResult AddCommentAction(int ProductIID, string ContentAddComment) { int CustomersID = 1; CommentDao pDao = new CommentDao(); pDao.InsertComment(ProductIID, CustomersID, ContentAddComment); string url = "/HomePage/Detail/" + ProductIID.ToString(); return(Redirect(url)); }
public ActionResult DeleteCommentAction(int id) { CommentDao cmDao = new CommentDao(); Comment cm = cmDao.FindCommentById(id); cmDao.DeleteComment(cm); string url = "/HomePage/Detail/" + _productID.ToString(); return(Redirect(url)); }
public ActionResult UpdateCommentAction(int IDComment, int ProductIID, string ContentComment_A) { int CustomersID = 1; CommentDao pDao = new CommentDao(); pDao.UpdateComment(IDComment, ProductIID, CustomersID, ContentComment_A); string url = "/HomePage/Detail/" + ProductIID.ToString(); return(Redirect(url)); }
public void UpdateComment(long commentId, string comment_text) { Comment comment; comment = CommentDao.Find(commentId); comment.comment_description = comment_text; //UpdateTagComment(commentId,tags); CommentDao.Update(comment); }
public ActionResult CommentsForArticle(int articleId) { ArticleDao aDao = new ArticleDao(); Article article = aDao.GetById(articleId); ViewBag.ArticleTitle = article.Title; ViewBag.ArticleId = article.Id; CommentDao cDao = new CommentDao(); return(View(cDao.GetByArticleId(article))); }
public void DeleteComment(long commentId, long userId) { Comment c = CommentDao.Find(commentId); if (c.UserProfile.usrId == userId) { CommentDao.Remove(commentId); //Remove no funciona } else { throw new Exception(); } }
public ICollection <CommentDto> FindAllComments(long eventId, int startIndex, int count) { Event myEvent = EventDao.Find(eventId); ICollection <Comment> comments = CommentDao.FindCommentsOrderByDate(eventId, startIndex, count); ICollection <CommentDto> commentsDto = new HashSet <CommentDto>(); foreach (Comment comment in comments) { commentsDto.Add(new CommentDto(comment, eventId)); } return(commentsDto); }
private Comment CreateTestComment(UserProfile user, Link link, string text, DateTime time) { Comment comment = Comment.CreateComment( TestData.nonExistentCommentId, user.userId, link.linkId, text, Trunk(time)); CommentDao.Create(comment); return(comment); }
public CommentBlock FindAllProductComments(long productId, int startIndex = 0, int count = 20) { List <Comment> comments = CommentDao.FindByProductIdOrderByDeliveryDate(productId, startIndex, count + 1); bool existMoreComments = (comments.Count == count + 1); if (existMoreComments) { comments.RemoveAt(count); } return(new CommentBlock(comments, existMoreComments)); }
/// <exception cref="InstanceNotFoundException"/> public long AddComment(long productId, long userId, string commentBody) { Comment comment = new Comment { comment1 = commentBody, commentDate = System.DateTime.Now, userId = userId, productId = productId }; CommentDao.Create(comment); return(comment.commentId); }
public Comment EditComment(long commentId, long userId, string newComment) { Comment c = CommentDao.Find(commentId); if (c.UserProfile.usrId == userId) { c.content = newComment; CommentDao.Update(c); } else { throw new Exception(); } return(c); }
public ICollection <LabelDto> GetCommentLabels(long commentId) { Comment comment = CommentDao.Find(commentId); ICollection <LabelDto> labelDtos = new List <LabelDto>(); foreach (Label l in comment.Labels) { ICollection <CommentDto> commentsDtos = new List <CommentDto>(); foreach (Comment c in l.Comments) { commentsDtos.Add(new CommentDto(c, c.Event.eventId)); } labelDtos.Add(new LabelDto(l.labelId, l.name, l.commentsNum, commentsDtos)); } return(labelDtos); }
public Comment AddLabel(long commentId, ICollection <Label> labels) { Comment c = CommentDao.Find(commentId); foreach (Label l in labels) { if (!c.Labels.Contains(l)) { c.Labels.Add(l); l.commentsNum++; LabelDao.Update(l); } } CommentDao.Update(c); return(c); }
public Comment RemoveLabel(long commentId, ICollection <Label> labels) { Comment comment = CommentDao.Find(commentId); foreach (Label l in labels) { if (comment.Labels.Contains(l)) { comment.Labels.Remove(l); l.commentsNum--; l.Comments.Remove(comment); LabelDao.Update(l); } } CommentDao.Update(comment); return(comment); }
public Comment AddComment(string comment, long eventId, long userId) { Event e = EventDao.Find(eventId); UserProfile u = UserProfileDao.Find(userId); Comment c = new Comment(); c.content = comment; c.Event = e; c.UserProfile = u; c.commentDate = DateTime.Now; c.Labels = new List <Label>(); c.loginName = u.loginName; CommentDao.Create(c); return(c); }
/// <exception cref="InstanceNotFoundException"/> public void UpdateComment(long commentId, string commentBody, List <long> newTags) { Comment comment = CommentDao.Find(commentId); ICollection <Tag> tags = new List <Tag>(); comment.comment1 = commentBody; comment.Tags.Clear(); foreach (var tagId in newTags) { tags.Add(TagDao.Find(tagId)); } comment.Tags = tags; CommentDao.Update(comment); }
public ActionResult Update(Comment comment, int articleId) { if (ModelState.IsValid) { CommentDao cDao = new CommentDao(); ArticleDao aDao = new ArticleDao(); comment.Article = aDao.GetById(articleId); cDao.Update(comment); TempData["message-success"] = "Komentář byl upraven"; } else { return(View("Edit", comment)); } return(RedirectToAction("CommentsForArticle", new RouteValueDictionary( new { controller = "Comments", action = "CommentsForArticle", articleId = comment.Article.Id }))); }