public void OnGet(int id)
        {
            Id   = id;
            user = _usersRepository.GetUser(id);

            AllComments = _commentsRepository.GetList(id);

            foreach (var a in AllComments)
            {
                if (AllComments == null)
                {
                    AllComments = new List <Comments>();
                }
                AllComments.AddRange(_commentsRepository.GetList(a.Id));
            }
        }
        public ActionResult GetComments(int id)
        {
            List <Comments>    comm   = db.Comments.Where(x => x.CommSharedModels.Id == id).OrderByDescending(x => x.CommDate).ToList();
            List <AllComments> allCom = new List <AllComments>();

            foreach (Comments item in comm)
            {
                AllComments comments = new AllComments();
                comments.Id           = item.Id;
                comments.CommDate     = item.CommDate.ToString();
                comments.CommImageUrl = item.CommSiteUsers.Resimulr;
                comments.CommText     = item.TextComments;
                comments.CommName     = item.CommSiteUsers.FirstName + " " + item.CommSiteUsers.LastName[0];
                allCom.Add(comments);
            }

            return(Json(allCom, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <PostInfo> AllComments;

            if (this.myConnection.PublishCommentPost(textBox1.Text, CurrentState.currentPostInfo))
            {
                textBox1.Clear();
                this.listBox3.Items.Clear();
                AllComments = myConnection.WatchAllComments(this.CurrentState.currentPostInfo);
                for (int i = 0; i < AllComments.Count; i++)
                {
                    listBox3.Items.Add(AllComments.ElementAt(i).msg + " ( " + AllComments.ElementAt(i).owner.fullname + " )");
                }
            }
            else
            {
                MessageBox.Show("לכאורה הפעולה אינו חוקית");
            }
        }
示例#4
0
    protected void AllComments_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        TextBox replyContent = (TextBox)e.Item.FindControl("ReplyInputContent");
        Button  replyButton  = (Button)e.Item.FindControl("Reply");

        switch (e.CommandName)
        {
        case "Reply":
            if (Session["UserID"] != null)
            {
                HiddenField   replyID    = (HiddenField)e.Item.FindControl("CommentID");
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineCourse"].ConnectionString);
                try
                {
                    connection.Open();
                    string sql = "INSERT INTO Comments(UserID,ClassID,Content,ReplyCommentID) VALUES ({0},{1},'{2}',{3})";
                    sql = string.Format(sql, Session["UserID"], Request["ClassID"], replyContent.Text, replyID.Value);
                    SqlCommand command = new SqlCommand(sql, connection);
                    command.ExecuteNonQuery();
                    replyContent.Text = "";
                    AllComments.DataBind();
                }
                catch (Exception ex)
                {
                    new Commom().ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), true);
                }
                finally
                {
                    connection.Close();
                }
            }
            else
            {
                Response.Write("<script>alert('您的登录信息失效,请登陆后评论!');</script>");
            }
            break;
        }
    }
示例#5
0
 public IEnumerable <Comment> InReplyTo(int id)
 => AllComments.Where(x => x.InReplyTo != null && x.InReplyTo.Id == id);
示例#6
0
 public IList <Comment> GetComments(Post post)
 {
     return(AllComments.Select(s => s.Child).ToList());
 }
 public IPageOfItems <Comment> GetComments(int pageIndex, int pageSize, Post post, bool includeUnapproved)
 {
     return(AllComments.AsQueryable().GetPage(pageIndex, pageSize));
 }