コード例 #1
0
        private void BindComments()
        {
            var context = CommentDb.Load();

            hdnForHighlighter.Value = context.SerializedHighlight;
            rptComments.DataSource  = context.Comments.Where(c => c.UserName.Equals(User.Identity.Name));
            rptComments.DataBind();
        }
コード例 #2
0
        // todo: ajax this
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var b       = sender as Button;
            var g       = new Guid(b.CommandArgument);
            var context = CommentDb.Load();

            context.Comments.First(x => x.ID.Equals(g)).Text = (b.Parent.FindControl("txtText") as TextBox).Text;
            CommentDb.Save(context);
        }
コード例 #3
0
        // todo: ajax this
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            var b       = sender as Button;
            var g       = new Guid(b.CommandArgument);
            var context = CommentDb.Load();

            context.Comments            = context.Comments.Where(c => !c.ID.Equals(g)).ToArray();
            context.SerializedHighlight = hdnForHighlighter.Value;
            CommentDb.Save(context);
            BindComments();
        }
コード例 #4
0
        // todo: ajax this
        protected void btnAddComment_Click(object sender, EventArgs e)
        {
            var context  = CommentDb.Load();
            var comments = context.Comments.ToList();

            comments.Add(new Comment {
                ID = Guid.NewGuid(), UserName = User.Identity.Name, SerializedSelection = hdnForAdd.Value
            });
            context.Comments            = comments.ToArray();
            context.SerializedHighlight = hdnForHighlighter.Value;
            CommentDb.Save(context);
            BindComments();
        }