public void AddOwnComment(OwnComments owncomment)
 {
     using (var db = new MysqlDataContext())
     {
         owncomment.CommentId = db.OwnComment.Max(o => o.CommentId) + 1;
         db.Add(owncomment);
         db.SaveChanges();
     }
 }
示例#2
0
 public static OwnCommentModel Map(OwnComments owncomment, IUrlHelper url)
 {
     return(new OwnCommentModel
     {
         Url = url.Link(Config.CommentRoute, new { id = owncomment.CommentId }),
         CommentCreated = owncomment.CommentCreated,
         CommentScore = owncomment.CommentScore,
         CommentText = owncomment.CommentText,
         PostId = owncomment.PostId
     });
 }
        public bool UpdateOwnComment(OwnComments own)
        {
            using (var db = new MysqlDataContext())
            {
                try
                {
                    db.Attach(own);
                    db.Entry(own).State = EntityState.Modified;
                    return(db.SaveChanges() > 0);
                }

                catch (DbUpdateConcurrencyException)
                {
                    return(false);
                }
            }
        }