public bool DeleteComment(CommentDto commentDto)
 {
     try
     {
         CommentDAO.Execute(Common.ConvertToComments(commentDto), Entity.COMMENT, ExecuteType.REMOVE);
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
Example #2
0
        public static CommentDto ConvertToCommentDto(Comments comment)
        {
            CommentDto newCommentDto = new CommentDto();
            if (comment != null)
            {
                newCommentDto.Content = comment.Content;
                newCommentDto.Name = comment.Name;
                newCommentDto.Phone = comment.Phone;
                newCommentDto.Title = comment.Title;
                newCommentDto.ProductId = comment.Product.Id;
                newCommentDto.CreatedDate = ((comment.CreatedDate != null) ? (DateTime)comment.CreatedDate : DateTime.Now);
            }
            else return null;

            return newCommentDto;
        }
 public ActionResult PostComment(String name, String phone, String content, String productId)
 {
     CommentDto comment = new CommentDto();
     comment.Name = name;
     try
     {
         comment.ProductId = int.Parse(productId);
     }
     catch (Exception ex)
     {
         comment.ProductId = 0;
     }
     comment.Phone = phone;
     comment.Content = content;
     ProductHandler prodHandler = new ProductHandler();
     prodHandler.AddComment(comment);
     return RedirectToAction("ProductDetail", "Home", new { productCode = productId });
 }
Example #4
0
 public static Comments ConvertToComments(CommentDto commentDto)
 {
     Comments comments = new Comments();
     if (commentDto != null)
     {
         comments.Title = commentDto.Title;
         comments.Status = StatusDAO.getStatusById(CONST.STATUS.ACTIVE);
         comments.Product = ProductDAO.getProductById(commentDto.ProductId);
         comments.Phone = commentDto.Phone;
         comments.Name = commentDto.Name;
         comments.Email = commentDto.Email;
         comments.CreatedDate = DateTime.Now;
         comments.Content = commentDto.Content;
     }
     return comments;
 }