public void CreateComment(Comment comment)
 {
     if(comment == null)
     {
         throw  new ArgumentNullException("comment","comment is null");
     }
     dbContext.Comments.Add(comment);
 }
        public void UpdateComment(Comment comment)
        {
            if (comment == null)
            {
                throw new ArgumentNullException("comment","comment is null");
            }

            Comment existComment = dbContext.Comments.FirstOrDefault(x => x.CommentId == comment.CommentId);
            if(existComment == null)
            {
                throw new InvalidDataException("This comment doesn't exist in current data base");
            }
            else
            {
                if (comment != existComment)
                {
                    CopyCommentsProperties(comment, existComment);
                }
                dbContext.Entry(existComment).State = System.Data.EntityState.Modified;
            }
        }
 private void CopyCommentsProperties(Comment fromComment, Comment toComment)
 {
     if(fromComment == null)
     {
         throw new ArgumentNullException("fromComment");
     }
     if(toComment == null)
     {
         throw new ArgumentNullException("toComment");
     }
     else
     {
         toComment.CreateDate = fromComment.CreateDate;
         toComment.PresentationId = fromComment.PresentationId;
         toComment.Text = fromComment.Text;
         toComment.UserId = fromComment.UserId;
     }
 }
 public void DeleteComment(Comment comment)
 {
     if(comment == null)
     {
         throw new ArgumentNullException("comment");
     }
     var existComment = dbContext.Comments.FirstOrDefault(x => x.CommentId == comment.CommentId);
     if(existComment != null)
     {
         dbContext.Comments.Remove(existComment);
     }
     else
     {
         throw  new InvalidDataException("This comment doesn't exist in current data base");
     }
 }