public bool UpdateComment(int id, CommentTagModel commentTag) { if (!ModelState.IsValid) { return(false); } if (Db.CommentTags.Any(ct => ct.Id == id)) { try { var updatedCommentTag = new CommentTag() { Id = id, FK_TagId = commentTag.FK_TagId, FK_CommentId = commentTag.FK_CommentId }; Db.CommentTags.Update(updatedCommentTag); Db.SaveChanges(); } catch (Exception ex) { return(false); } } return(true); }
public Task <PageResponse <Comment> > GetList(CommentTag commentTag, string subjectId, int pageNumber, int pageSize) { return(dbContext.Comments .Where(x => x.Tag == commentTag && x.SubjectId == subjectId) .OrderByDescending(x => x.CreatedAt) .PickPageAsync(pageNumber, pageSize, x => x.ToContract())); }
public Comment(string content, DateTime createdAt, CommentTag tag, string subjectId) { Content = content; CreatedAt = createdAt; Tag = tag; SubjectId = subjectId; WasEdited = false; }
public Task <PageResponse <Comment> > GetList( CommentTag tag, string subjectId, int pageNumber = RequestDefaults.PageNumber, int pageSize = RequestDefaults.PageSize) { return(service.GetList(tag, subjectId, pageNumber, pageSize)); }
private void RemovecommentTag(CommentTag item, int commID) { _tag.RemoveCommentTag(item.Tag_Id, commID); //get list of ID //remove postTag //remove tag if (_tag.IfPostOrCommentHaveTags(item.Tag_Id)) { _tag.RemoveTagsIfNotUsed(item.Tag_Id); _tag.SaveChanges(); } }
/// <summary> /// 分析标签 /// </summary> /// <param name="parser">TemplateParser</param> /// <param name="tc">Token集合</param> /// <returns></returns> public ITag Parse(TemplateParser parser, TokenCollection tc) { if (tc != null && tc.Count == 1 && tc[0].TokenKind == TokenKind.Comment ) { CommentTag tag = new CommentTag(); tag.FirstToken = tc[0]; return(tag); } return(null); }
private void SeedCommentTag(BlogContext context) { for (int i = 1; i < 11; i++) { var comtag = new CommentTag { Comment_Id = i, Tag_Id = i }; context.Set <CommentTag>().AddOrUpdate(comtag); } context.SaveChanges(); }
public ActionResult Create([Bind(Include = "Post_Id,Content,User_Id,ID,AddingDate,Votes,EditingDate")] Comment comment) { comment.Votes = 0; comment.AddingDate = DateTime.Now; //load from users: var nullableUserID = _user.GetIDOfCurrentlyLoggedUser(); if (nullableUserID == null) { return(RedirectToAction("LogIn", "User")); } else { //int? to int comment.User_Id = nullableUserID.GetValueOrDefault(); } comment.EditingDate = null; var result = new { result = true }; if (ModelState.IsValid) { _comm.Add(comment); _comm.SaveChanges(); MatchCollection matches = Regex.Matches(comment.Content, @"\B(\#[a-zA-Z0-9-,_]+\b)"); //wpis ID first important foreach (var tagName in matches) { var tag = _tag.GetTagByName(tagName.ToString()); if (tag == null) { tag = new Tag(); tag.TagName = tagName.ToString().ToLower(); //id radnom _tag.Add(tag); _tag.SaveChanges(); } var commTag = new CommentTag() { Tag_Id = tag.Tag_Id, Comment_Id = comment.Comment_Id }; _comm.Add(commTag); _comm.SaveChanges(); } return(RedirectToAction("Index", "Post")); } return(RedirectToAction("Index", "Post")); }
/// <summary>Parses .Net XML documentation for permission or exception.</summary> /// <example><![CDATA[<permission cref="Namespace.Type.Member">nested comments</permission>]]></example> /// <example><![CDATA[<exception cref="Namespace.ExceptionType">nested comments</exception>]]></example> public static new DotNetCommentQualifiedLinkedGroup FromVisualStudioXml(XElement element) { ValidateXmlTag(element, new string[] { "permission", "exception", "see", "seealso" }); CommentTag tag = DotNetComment.GetTag(element); DotNetCommentQualifiedLink link = DotNetCommentQualifiedLink.FromVisualStudioXml(element.GetAttributeValue("cref")); List <DotNetComment> comments = ParseSection(element); if (link is DotNetCommentMethodLink) { return(new DotNetCommentMethodLinkedGroup(link as DotNetCommentMethodLink, tag, comments)); } return(new DotNetCommentQualifiedLinkedGroup(link, tag, comments)); }
private void RemovecommentAndCommentTags(Comment comment, object tag) { //check if exist in tag base //if not add tag and postTag //1. get tag from DB tags by tag name var tagz = _tag.GetTagByName(tag.ToString().ToLower()); // if no existing add it if (tagz == null) { tagz = new Tag(); tagz.TagName = tag.ToString().ToLower(); //id radnom _tag.Add(tagz); _tag.SaveChanges(); var commTag = new CommentTag() { Tag_Id = tagz.Tag_Id, Comment_Id = comment.Comment_Id }; _comm.Add(commTag); _comm.SaveChanges(); } //if not existing in listOfTagNames but used somewhere else: else { //remove removeCommVote (get by tagID and CommID) int tagID = tagz.Tag_Id; int commID = comment.Comment_Id; _tag.RemoveCommentTag(tagID, commID); var commTag = new CommentTag() { Tag_Id = tagz.Tag_Id, Comment_Id = comment.Comment_Id }; _comm.Add(commTag); _comm.SaveChanges(); } }
public bool SaveComment(CommentTagModel commentTag) { // TODO! Need to bring the user and article/post id to presist comment if (!ModelState.IsValid) { return(false); } try { CommentTag newCommentTag = new CommentTag() { FK_CommentId = commentTag.FK_CommentId, FK_TagId = commentTag.FK_TagId }; Db.Add <CommentTag>(newCommentTag); Db.SaveChanges(); } catch (Exception ex) { return(false); } return(true); }
public void TestInitialize() { this.element = new CommentTag(); this.provider = this.element; }
/// <summary></summary> public DotNetCommentGroup(CommentTag tag, params DotNetComment[] comments) { Tag = tag; Comments.AddRange(comments); }
/// <summary></summary> public DotNetCommentQualifiedLinkedGroup(DotNetCommentQualifiedLink link, CommentTag tag, List <DotNetComment> comments) : base(link, comments) { Tag = tag; }
/// <summary></summary> public DotNetCommentMethodLinkedGroup(DotNetCommentMethodLink link, CommentTag tag, params DotNetComment[] comments) : base(link, tag, comments) { }
/// <summary></summary> public DotNetCommentTypeParameterLink(string name, CommentTag tag) : base(name) { Tag = tag; }
/// <summary></summary> public DotNetCommentGroup(CommentTag tag, DotNetComment comment) { Tag = tag; Comments.Add(comment); }
/// <summary></summary> public DotNetCommentGroup(CommentTag tag, List <DotNetComment> comments) { Tag = tag; Comments.AddRange(comments); }
/// <summary></summary> public DotNetCommentMethodLinkedGroup(DotNetCommentMethodLink link, CommentTag tag, DotNetComment comment) : base(link, tag, comment) { }
public void Add(CommentTag commTag) { _db.CommentTags.Add(commTag); }
/// <summary></summary> public DotNetCommentQualifiedLink(DotNetQualifiedName name, CommentTag tag) { Name = name; Tag = tag; }
public void SetUp() { tag = new CommentTag(); }
/// <summary></summary> public DotNetCommentQualifiedLinkedGroup(DotNetCommentQualifiedLink link, CommentTag tag, DotNetComment comment) : base(link, comment) { Tag = tag; }
/// <summary></summary> public DotNetCommentQualifiedLinkedGroup(DotNetCommentQualifiedLink link, CommentTag tag, params DotNetComment[] comments) : base(link, comments) { Tag = tag; }
/// <summary></summary> public DotNetCommentMethodLinkedGroup(DotNetCommentMethodLink link, CommentTag tag, List <DotNetComment> comments) : base(link, tag, comments) { }
/// <summary></summary> public DotNetCommentParameterLink(string name, CommentTag tag) { Name = name; Tag = tag; }
/// <summary></summary> public DotNetCommentGroup(CommentTag tag) { Tag = tag; }