public void RemoveAnnotation(IAnnotation annotation) { removedAnnotation = annotation; removedIndex = CommentCollection.IndexOf(annotation.Comments[0]); CommentCollection.Remove(annotation.Comments[0]); AnnotationCount = CommentCollection.Count.ToString(); }
private void BuildPage() { if (Request.QueryString["id"] == null) { //CommentCollection cc = new CommentCollection(); Query q = Comment.CreateQuery(); if (!(Request.QueryString["a"] == "d")) { q.AndWhere(Comment.Columns.IsPublished, !(Request.QueryString["a"] == "f")); } q.AndWhere(Comment.Columns.IsDeleted, (Request.QueryString["a"] == "d")); if (!String.IsNullOrEmpty(Request.QueryString["pid"])) { q.AndWhere(Comment.Columns.PostId, Request.QueryString["pid"]); } q.OrderByDesc(Comment.Columns.Id); CommentCollection tempCC = CommentCollection.FetchByQuery(q); CommentCollection permissionsFilteredCount = new CommentCollection(); permissionsFilteredCount.AddRange(tempCC); foreach (Comment c in tempCC) { if (!RolePermissionManager.GetPermissions(c.Post.CategoryId, GraffitiUsers.Current).Read) { permissionsFilteredCount.Remove(c); } } q.PageIndex = Int32.Parse(Request.QueryString["p"] ?? "1"); q.PageSize = 25; CommentCollection cc = CommentCollection.FetchByQuery(q); CommentCollection permissionsFiltered = new CommentCollection(); permissionsFiltered.AddRange(cc); foreach (Comment c in cc) { if (!RolePermissionManager.GetPermissions(c.Post.CategoryId, GraffitiUsers.Current).Read) { permissionsFiltered.Remove(c); } } CommentList.DataSource = permissionsFiltered; CommentList.DataBind(); string qs = Request.QueryString["a"] != null ? "?a=" + Request.QueryString["a"] : "?a=t"; Pager.Text = Util.Pager(q.PageIndex, q.PageSize, permissionsFilteredCount.Count, "navigation", qs); if (Request.QueryString["a"] == "f") { CommentLinks.SetActiveView(PendingComments); } else if (Request.QueryString["a"] == "d") { CommentLinks.SetActiveView(DeletedComments); } } else { the_Views.SetActiveView(Comment_Form); Comment comment = new Comment(Request.QueryString["id"]); if (comment.IsNew) { throw new Exception("Invalid Comment Id"); } txtName.Text = Server.HtmlDecode(comment.Name); txtSite.Text = comment.WebSite; txtEmail.Text = comment.Email; CommentEditor.Text = comment.Body; } #region build the page title StringBuilder sb = new StringBuilder(); string page = Request.QueryString["a"] ?? "t"; switch (page) { case "t": sb.Append("Published "); break; case "f": sb.Append("Pending "); break; case "d": sb.Append("Deleted "); break; } sb.Append(" Comments"); lblPageTitle.Text = sb.ToString(); string post = Request.QueryString["pid"]; if (!String.IsNullOrEmpty(post)) { Post p = new Post(Convert.ToInt32(post)); lblPageTitle.Text += " for \"" + p.Name + "\""; } #endregion }
private void BuildPage() { if (Request.QueryString["id"] == null) { //CommentCollection cc = new CommentCollection(); Query q = Comment.CreateQuery(); if (!(Request.QueryString["a"] == "d")) q.AndWhere(Comment.Columns.IsPublished, !(Request.QueryString["a"] == "f")); q.AndWhere(Comment.Columns.IsDeleted, (Request.QueryString["a"] == "d")); if (!String.IsNullOrEmpty(Request.QueryString["pid"])) { q.AndWhere(Comment.Columns.PostId, Request.QueryString["pid"]); } q.OrderByDesc(Comment.Columns.Id); CommentCollection tempCC = CommentCollection.FetchByQuery(q); CommentCollection permissionsFilteredCount = new CommentCollection(); permissionsFilteredCount.AddRange(tempCC); foreach (Comment c in tempCC) { if (!RolePermissionManager.GetPermissions(c.Post.CategoryId, GraffitiUsers.Current).Read) permissionsFilteredCount.Remove(c); } q.PageIndex = Int32.Parse(Request.QueryString["p"] ?? "1"); q.PageSize = 25; CommentCollection cc = CommentCollection.FetchByQuery(q); CommentCollection permissionsFiltered = new CommentCollection(); permissionsFiltered.AddRange(cc); foreach (Comment c in cc) { if (!RolePermissionManager.GetPermissions(c.Post.CategoryId, GraffitiUsers.Current).Read) permissionsFiltered.Remove(c); } CommentList.DataSource = permissionsFiltered; CommentList.DataBind(); string qs = Request.QueryString["a"] != null ? "?a=" + Request.QueryString["a"] : "?a=t"; Pager.Text = Util.Pager(q.PageIndex, q.PageSize, permissionsFilteredCount.Count, "navigation", qs); if (Request.QueryString["a"] == "f") CommentLinks.SetActiveView(PendingComments); else if (Request.QueryString["a"] == "d") CommentLinks.SetActiveView(DeletedComments); } else { the_Views.SetActiveView(Comment_Form); Comment comment = new Comment(Request.QueryString["id"]); if (comment.IsNew) throw new Exception("Invalid Comment Id"); txtName.Text = Server.HtmlDecode(comment.Name); txtSite.Text = comment.WebSite; txtEmail.Text = comment.Email; CommentEditor.Text = comment.Body; } #region build the page title StringBuilder sb = new StringBuilder(); string page = Request.QueryString["a"] ?? "t"; switch (page) { case "t": sb.Append("Published "); break; case "f": sb.Append("Pending "); break; case "d": sb.Append("Deleted "); break; } sb.Append(" Comments"); lblPageTitle.Text = sb.ToString(); string post = Request.QueryString["pid"]; if (!String.IsNullOrEmpty(post)) { Post p = new Post(Convert.ToInt32(post)); lblPageTitle.Text += " for \"" + p.Name + "\""; } #endregion }