Exemplo n.º 1
0
        public List <CommentDetailDTO> GetApprovedComments()
        {
            List <Comment>          list    = db.Comments.Where(x => x.IsApproved == true).ToList();
            List <CommentDetailDTO> dtoList = new List <CommentDetailDTO>();

            foreach (var item in list)
            {
                CommentDetailDTO dto = new CommentDetailDTO();
                dto.ID             = item.ID;
                dto.Title          = item.Title;
                dto.CommentContent = item.CommentContent;
                dto.MemberID       = item.MemberID;
                dto.Member         = item.Member.Name;
                dto.AddDate        = item.AddDate;
                dto.CategoryID     = (int)item.CategoryID;
                dto.CategoryName   = item.CommentCategory.Name;
                dto.IsApproved     = item.IsApproved;
                dto.Rating         = item.Rating;
                dto.Feedback       = item.Feedback;
                if (item.MealOptionID != null)
                {
                    dto.MealOptionID = (int)item.MealOptionID;
                    dto.MealName     = item.MealOption.Name;
                }
                dtoList.Add(dto);
            }
            return(dtoList);
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (!txtTitle.Enabled)
     {
         ClearTextboxes(); // Clear textboxes first.
     }
     else if (txtTitle.Text == "" || txtComment.Text == "")
     {
         MessageBox.Show("請填入所有欄位"); // Empty control.
     }
     else
     {
         detail                = new CommentDetailDTO();
         detail.Title          = txtTitle.Text;
         detail.CommentContent = txtComment.Text;
         detail.CategoryID     = Convert.ToInt32(cmbCategory.SelectedValue);
         detail.Rating         = Convert.ToInt32(numericRating.Value);
         detail.MemberID       = UserStatic.UserID;
         detail.IsApproved     = false;
         detail.AddDate        = DateTime.Now;
         if (detail.CategoryID == General.CommentCategory.meal)
         {
             detail.MealOptionID = Convert.ToInt32(cmbMeals.SelectedValue);
         }
         commentBLL.Add(detail);
         MessageBox.Show("已新增留言");
         ClearTextboxes();
         ShowComments(); // Refresh page. => Won't show comment before approved.
     }
 }
Exemplo n.º 3
0
        public void Update(CommentDetailDTO entity)
        {
            Comment comment = new Comment();

            comment.ID             = entity.ID;
            comment.Title          = entity.Title;
            comment.CommentContent = entity.CommentContent;
            comment.Rating         = entity.Rating;
            comment.IsApproved     = entity.IsApproved;
            comment.CategoryID     = entity.CategoryID;
            comment.MealOptionID   = entity.MealOptionID;
            comment.Feedback       = entity.Feedback;
            commentDAO.Update(comment);
        }
Exemplo n.º 4
0
        public void Add(CommentDetailDTO entity)
        {
            Comment comment = new Comment();

            comment.Title          = entity.Title;
            comment.CommentContent = entity.CommentContent;
            comment.MemberID       = entity.MemberID;
            comment.AddDate        = entity.AddDate;
            comment.CategoryID     = entity.CategoryID;
            comment.IsApproved     = entity.IsApproved;
            comment.Rating         = entity.Rating;
            comment.Feedback       = entity.Feedback;
            if (entity.MealOptionID != null)
            {
                comment.MealOptionID = (int)entity.MealOptionID;
            }
            commentDAO.Add(comment);
        }
Exemplo n.º 5
0
        public ActionResult Delete(CommentDetailDTO dto)
        {
            var svc = GetCommentService();
            var rao = new CommentDetailRAO
            {
                CommentId = dto.CommentId,
                Content   = dto.Content,
                GroupId   = dto.GroupId
            };

            if (svc.DeleteComment(rao))
            {
                return(RedirectToAction("Index", "Group", new { id = dto.GroupId }));
            }
            else
            {
                return(RedirectToAction("Index", "Group", new { id = dto.GroupId }));
            }
        }