/// <summary>
 /// Create new comment and add it to database.
 /// </summary>
 /// <param name="comment"></param>
 public void Create(DalComment comment)
 {
     if (comment == null)
         throw new ArgumentNullException(nameof(comment));
     comment.CreationDateTime = DateTime.Now;
     context.Set<Comment>().Add(comment.ToOrmComment());
 }
Пример #2
0
        public void UpdateComment(DalComment comment)
        {
            var original = context.Set<Comment>().First(u => u.Id == comment.Id);

            var updatedComment = comment.ToOrmComment();
            if (updatedComment.Text != null)
                original.Text = updatedComment.Text;
        }
Пример #3
0
 public void DeleteComment(DalComment e)
 {
     var comment = e.ToOrmComment();
     comment = context.Set<Comment>().Single(c => c.Id == comment.Id);
     context.Set<Comment>().Remove(comment);
 }
Пример #4
0
 public void AddComment(DalComment e)
 {
     var comment = e.ToOrmComment();
     comment.Date = DateTime.Now;
     comment.User = context.Set<User>().Find(e.User.Id);
     comment.Content = context.Set<Content>().Find(e.ContentId);
     context.Set<Comment>().Add(comment);
 }