/// <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()); }
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; }
public void DeleteComment(DalComment e) { var comment = e.ToOrmComment(); comment = context.Set<Comment>().Single(c => c.Id == comment.Id); context.Set<Comment>().Remove(comment); }
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); }