Exemplo n.º 1
0
        private void Comment(string[] args)
        {
            if (args.Length < 2)
            {
                PrintError(NotEnoughParametersError);
                return;
            }
            if (!IsAutorize())
            {
                PrintError(NotAutorizedError);
                return;
            }

            int topicId;

            if (Int32.TryParse(args[1], out topicId))
            {
                var comment = new BllComment
                {
                    Text   = ReadString("Text"),
                    Sender = me,
                    Topic  = new BllTopic {
                        Id = topicId
                    },
                };
                commentService.AddComment(comment);

                Topic(new string[] { null, topicId.ToString() });
            }
        }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            int id         = Convert.ToInt32(context.Request["pId"]);
            int pageSize   = Convert.ToInt32(context.Request["pSize"]);
            int pageIndex  = Convert.ToInt32(context.Request["pIndex"]);
            int totalCount = new BllComment().SelectRowCount(id);
            int pageCount  = 1;

            var list = new BllComment().SelectCommentInfo(pageSize, pageIndex, id);

            if (totalCount % pageSize > 0)
            {
                pageCount = totalCount / pageSize + 1;
            }
            else
            {
                pageCount = totalCount / pageSize;
            }
            CommentListPageCount view = new CommentListPageCount();

            view.List      = list;
            view.PageCount = pageCount;

            string str = new JavaScriptSerializer().Serialize(view);

            context.Response.Write(str);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update comment
        /// </summary>
        /// <param name="e">Updated comment entity</param>
        /// <exception cref="ArgumentNullException"></exception>
        public async Task Update(BllComment e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            await context.CommentsRepository.Update(e.ToDalCommentary());
        }
Exemplo n.º 4
0
 public static CommentViewModel ToCommentViewModel(this BllComment comment)
 {
     return(new CommentViewModel()
     {
         Id = comment.Id,
         Text = comment.Text,
         Author = comment.Author.ToAuthor()
     });
 }
Exemplo n.º 5
0
        public ActionResult MarkCommentAsGood(int id)
        {
            BllComment comment   = commentService.GetComment(id);
            bool       isCanMark = comment.Topic.Author.Id == userService.GetUser(User.Identity.Name).Id;

            isCanMark       |= User.IsInRole("Admin") || User.IsInRole("Moderator");
            comment.IsAnswer = isCanMark;
            commentService.UpdateComment(comment);
            return(RedirectToAction("Topic", "Home", new { Id = comment.Topic.Id }));
        }
Exemplo n.º 6
0
 public ActionResult Comment(AddEditCommentModel comment)
 {
     if (ModelState.IsValid)
     {
         BllComment bllComment = comment.ToBllComment();
         bllComment.Sender = userService.GetUser(User.Identity.Name);
         commentService.AddComment(bllComment);
     }
     return(RedirectToAction("Topic", "Home", new { id = comment.TopicId }));
 }
Exemplo n.º 7
0
 public static DalComment ToDal(this BllComment comment)
 {
     return(new DalComment
     {
         Id = comment.Id,
         Content = comment.Content,
         PostId = comment.PostId,
         UserId = comment.UserId
     });
 }
Exemplo n.º 8
0
 public static AddEditCommentModel ToAddEditCommentModel(this BllComment bllComment)
 {
     return(new AddEditCommentModel
     {
         Id = bllComment.Id,
         Text = bllComment.Text,
         TopicId = bllComment.Topic.Id,
         IsAnswer = bllComment.IsAnswer,
     });
 }
Exemplo n.º 9
0
 public static DalComment ToDalComment(this BllComment bllComment)
 {
     return(new DalComment()
     {
         Id = bllComment.Id,
         Description = bllComment.Description,
         DateOfSending = bllComment.DateOfSending,
         PhotoId = bllComment.PhotoId,
         UserId = bllComment.UserId
     });
 }
Exemplo n.º 10
0
 public static CommentViewModel ToMvcComment(this BllComment bllComment)
 {
     return(new CommentViewModel()
     {
         Id = bllComment.Id,
         Description = bllComment.Description,
         DateOfSending = bllComment.DateOfSending,
         PhotoId = bllComment.PhotoId,
         UserId = bllComment.UserId
     });
 }
Exemplo n.º 11
0
 public static DalCommentary ToDalCommentary(this BllComment comment)
 {
     return(new DalCommentary()
     {
         Id = comment.Id,
         Date = comment.Date,
         Text = comment.Text,
         Lot = comment.Lot,
         User = comment.User
     });
 }
Exemplo n.º 12
0
 public static DalComment ToDalComment(this BllComment comment)
 {
     return(new DalComment()
     {
         Id = comment.CommentId,
         CreationDate = comment.CreationDate,
         Text = comment.Text,
         Author = comment.Author?.ToDalUser(),
         Article = comment.Article?.ToDalArticle()
     });
 }
Exemplo n.º 13
0
 public static CommentViewModel ToViewModel(this BllComment comment, BllUser user)
 {
     return(new CommentViewModel()
     {
         Content = comment.Content,
         Id = comment.Id,
         PostId = comment.PostId,
         FirstName = user.FirstName,
         LastName = user.LastName,
         UserId = user.Id
     });
 }
Exemplo n.º 14
0
 public static CommentModel ToCommentModel(this BllComment bllComment)
 {
     return(new CommentModel
     {
         Id = bllComment.Id,
         Text = bllComment.Text,
         Date = bllComment.Date,
         IsAnswer = bllComment.IsAnswer,
         Status = bllComment.Status.Name,
         Sender = bllComment.Sender?.ToShortUserModel(),
     });
 }
Exemplo n.º 15
0
        public ActionResult GetRawComment()
        {
            BllComment comment = commentService.GetRawComment();

            if (comment != null)
            {
                return(RedirectToAction("EditComment", new { id = comment.Id }));
            }
            else
            {
                return(View("Info", (object)"All comments are processed."));
            }
        }
Exemplo n.º 16
0
 private ActionResult ChangeCommentState(AddEditCommentModel comment, StatusEnum status)
 {
     if (ModelState.IsValid)
     {
         BllComment bllComment = comment.ToBllComment();
         bllComment.Status = new BllStatus {
             Id = (int)status
         };
         commentService.UpdateComment(bllComment);
         return(RedirectToAction("Topic", "Home", new { id = comment.TopicId }));
     }
     return(View("EditComment", comment));
 }
        public static Comment ToMvcComment(this BllComment comment, IUserService userService)
        {
            Task <BllUser> task = Task.Run(() => userService.GetById(comment.User));

            task.Wait();

            return(new Comment()
            {
                Id = comment.Id,
                UserId = comment.User,
                PubDate = comment.Date,
                Text = comment.Text,
                UserName = task.Result.Login,
                LotId = comment.Lot
            });
        }
Exemplo n.º 18
0
 public static DalComment ToDalComment(this BllComment bllComment)
 {
     return(new DalComment
     {
         Id = bllComment.Id,
         Text = bllComment.Text,
         Date = bllComment.Date,
         IsAnswer = bllComment.IsAnswer,
         Topic = new DalTopic()
         {
             Id = bllComment.Topic.Id
         },
         Sender = bllComment.Sender.ToDalUser(),
         Status = bllComment.Status.ToDalStatus()
     });
 }
Exemplo n.º 19
0
        public void AddComment(BllComment comment)
        {
            comment.Date   = DateTime.Now;
            comment.Status = new BllStatus()
            {
                Id = 1
            };

            try
            {
                commentRepository.Add(comment.ToDalComment());
            }
            catch (InvalidOperationException e)
            {
                logger.Warn(e.Message);
                throw;
            }
        }
Exemplo n.º 20
0
        public ActionResult Add(CommentViewModel comment)
        {
            if (ModelState.IsValid)
            {
                var bllComment = new BllComment()
                {
                    CreationDate = DateTime.Now,
                    Text         = comment.Text,
                    Author       = userService.GetUserEntity(comment.AuthorEmail),
                    Article      = articleService.GetArticle(comment.ArticleId)
                };

                commentService.CreateComment(bllComment);
            }
            if (Request.IsAjaxRequest())
            {
                return(Index(comment.ArticleId));
            }
            return(RedirectToAction("Details", "Article", new { id = comment.ArticleId }));
        }
Exemplo n.º 21
0
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            //获取前台的comm方法名
            string name = e.CommandName;
            //存储model值
            ModelComment model = new ModelComment()
            {
                commentid = Convert.ToInt32(e.CommandArgument)
            };

            //判断方法名来进行相对的操作
            if (name == "delete")
            {
                //执行删除(软删除,将值隐藏)
                int num = BllComment.delete(model);
                if (num > 0)
                {
                    Response.Write("<script>alert('删除成功');location.href='Comment.aspx'</script>");
                }
            }
        }
Exemplo n.º 22
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "")
            {
                Response.Write("<script>alert('请评价')</script>");
            }
            //if (TextBox2.Text=="")
            //{
            //    Response.Write("<script>alert('请输入卖家商品id')</script>");
            //}
            //var qq = Session["Product"] as ModelSproduct;
            ModelComment ins = new ModelComment()
            {
                commentcontent = TextBox1.Text,
                commenttime    = TextBox2.Text
                                 //Sproductid=Convert.ToInt32(TextBox2.Text)
            };

            if (BllComment.insert(ins) > 0)
            {
                Response.Write("<script>alert('添加成功');location.href='Comment.aspx'</script>");
            }
        }
Exemplo n.º 23
0
        public void UpdateComment(BllComment comment)
        {
            DalComment dalComment = commentRepository.First(c => c.Id == comment.Id);

            dalComment.IsAnswer  = comment.IsAnswer;
            dalComment.Text      = comment.Text;
            dalComment.Status.Id = comment.Status.Id;

            dalComment.Topic.IsAnswered = dalComment.IsAnswer;
            topicRepository.Update(dalComment.Topic);


            try
            {
                topicRepository.Update(dalComment.Topic);
                commentRepository.Update(dalComment);
            }
            catch (InvalidOperationException e)
            {
                logger.Warn(e.Message);
                throw;
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Add comment
        /// </summary>
        /// <param name="text">Comment text</param>
        /// <param name="userName">User login</param>
        /// <param name="lotId">Id of the lot</param>
        /// <returns>Id of added comment</returns>
        public async Task <int> PostComment(string text, string userName, int lotId)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException(nameof(text));
            }

            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException(nameof(userName));
            }

            var user = (await context.UserStore.FindByNameAsync(userName)).ToBllUser();

            var comment = new BllComment()
            {
                Date = DateTime.Now,
                Lot  = lotId,
                Text = text,
                User = user.Id
            };

            return(await context.CommentsRepository.Create(comment.ToDalCommentary()));
        }
Exemplo n.º 25
0
 async Task IService <BllComment, int> .Delete(BllComment e)
 {
     await Delete(e.Id);
 }
Exemplo n.º 26
0
        async Task <int> IService <BllComment, int> .Create(BllComment e)
        {
            string userName = (await context.UserStore.FindByIdAsync(e.User)).UserName;

            return(await PostComment(e.Text, userName, e.Lot));
        }
Exemplo n.º 27
0
 public void AddComment(BllComment comment)
 {
     commentRepository.Insert(comment.ToDalComment());
 }
Exemplo n.º 28
0
 public void CreateComment(BllComment comment)
 {
     commentRepository.Create(comment.ToDalComment());
     uow.Commit();
 }
Exemplo n.º 29
0
 public void DeleteComment(BllComment comment)
 {
     commentRepository.Delete(comment.ToDalComment());
     uow.Commit();
 }
Exemplo n.º 30
0
 public void Delete(BllComment entity)
 {
     repository.Delete(entity.ToDal());
     unitOfWork.Commit();
 }