本文整理汇总了C#中Comment.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Comment.Save方法的具体用法?C# Comment.Save怎么用?C# Comment.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment.Save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateComment
public ActionResult CreateComment(string id, FormCollection collection)
{
int postId = 0;
int.TryParse(id, out postId);
Post post = Post.Find(postId);
Comment comment = new Comment();
comment.Post = post;
comment.Auther = Request.Form["Author"];
comment.DateAdded = DateTime.Now;
comment.Text = Request.Form["Comment"];
comment.Save();
return Details(post.Id.ToString());
}
示例2: Insert
public void Insert(int? CommentType,string Comments,DateTime? DateAdded,string RoleAccess,string UserID,int? SourceType,int? SourceID,bool Deleted,DateTime? DateModified,DateTime? DeletedDate)
{
Comment item = new Comment();
item.CommentType = CommentType;
item.Comments = Comments;
item.DateAdded = DateAdded;
item.RoleAccess = RoleAccess;
item.UserID = UserID;
item.SourceType = SourceType;
item.SourceID = SourceID;
item.Deleted = Deleted;
item.DateModified = DateModified;
item.DeletedDate = DeletedDate;
item.Save(UserName);
}
示例3: CommentSave_Click
protected void CommentSave_Click(object sender, EventArgs e)
{
Comment comment = new Comment(Request.QueryString["id"]);
if (comment.IsNew)
throw new Exception("Invalid Comment Id");
comment.Body = CommentEditor.Text;
comment.Name = Server.HtmlEncode(txtName.Text);
comment.WebSite = txtSite.Text;
comment.Email = txtEmail.Text;
comment.Save();
Response.Redirect("~/graffiti-admin/comments/");
}
示例4: UpdateComment
private static string UpdateComment(XmlDocument doc, IGraffitiUser user)
{
int id = Int32.Parse(doc.SelectSingleNode("/comment").Attributes["id"].Value);
Comment comment = new Comment(id);
if(comment.IsNew)
throw new Exception("Comment with id " + id + " does not exist. The REST API only supports updating existing comments at this time.");
XmlNode node = doc.SelectSingleNode("/comment");
comment.Body = GetNodeValue(node.SelectSingleNode("body"), comment.Body);
comment.Name = GetNodeValue(node.SelectSingleNode("name"), comment.Name);
comment.IsPublished = GetNodeValue(node.SelectSingleNode("isPublished"), comment.IsPublished);
comment.IsDeleted = GetNodeValue(node.SelectSingleNode("isDeleted"), comment.IsDeleted);
comment.SpamScore = GetNodeValue(node.SelectSingleNode("spamScore"), comment.SpamScore);
comment.Email = GetNodeValue(node.SelectSingleNode("email"), comment.Email);
comment.WebSite = GetNodeValue(node.SelectSingleNode("webSite"), comment.WebSite);
if (!RolePermissionManager.GetPermissions(comment.Post.CategoryId, user).Edit)
throw new Exception("You do not have sufficient privileges to update this comment.");
comment.Save(GraffitiUsers.Current.Name);
return "<result id=\"" + id + "\">true</result>";
}
示例5: CommentList_OnItemCommand
protected void CommentList_OnItemCommand(object sender, RepeaterCommandEventArgs e)
{
int count = 0;
switch (e.CommandName)
{
case "Delete":
foreach (RepeaterItem item in CommentList.Items)
{
int id = Convert.ToInt32(((HiddenField)item.FindControl("CommentID")).Value);
if (((CheckBox)item.FindControl("CommentCheckbox")).Checked)
{
Comment.Delete(id);
count++;
}
}
CommentStatus.Text = "You have deleted " + count.ToString() + " comment(s).";
break;
case "Approve":
foreach (RepeaterItem item in CommentList.Items)
{
int id = Convert.ToInt32(((HiddenField)item.FindControl("CommentID")).Value);
if (((CheckBox)item.FindControl("CommentCheckbox")).Checked)
{
Comment cmt = new Comment(id);
cmt.IsDeleted = false;
cmt.IsPublished = true;
cmt.Save();
count++;
}
}
CommentStatus.Text = "You have approved " + count.ToString() + " comment(s).";
break;
case "Undelete":
foreach (RepeaterItem item in CommentList.Items)
{
int id = Convert.ToInt32(((HiddenField)item.FindControl("CommentID")).Value);
if (((CheckBox)item.FindControl("CommentCheckbox")).Checked)
{
Comment comment = new Comment(id);
comment.IsDeleted = false;
comment.Save();
count++;
}
}
CommentStatus.Text = "You have undeleted " + count.ToString() + " comment(s).";
break;
}
if (count == 0)
{
CommentStatus.Type = StatusType.Warning;
CommentStatus.Text = "No comments were selected.";
}
else
{
CommentStatus.Type = StatusType.Success;
}
BuildPage();
}