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 Update(DalComment entity) { var filter = Builders <Comment> .Filter.Eq(u => u.Id, entity.Id); modelContext.Comments.ReplaceOne(filter, entity.ToOrmComment(), new UpdateOptions() { IsUpsert = true }); }
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); }
/// <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 int Create(DalComment entity) { var dbBook = context.Books.FirstOrDefault(e => e.BookID == entity.BookID); var dbUser = context.Users.FirstOrDefault(e => e.UserID == entity.UserID); if (dbBook != null && dbUser != null) { context.Comments.Add(entity.ToOrmComment()); } return(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; } }
/// <summary> /// Creates new comment entity /// </summary> /// <param name="e">Base entity for new comment entity</param> public void Create(DalComment e) { context.Set <Comment>().Add(e.ToOrmComment()); }
public void Insert(DalComment entity) { entity.Id = GetId() + 1; modelContext.Comments.InsertOne(entity.ToOrmComment()); }
public void Create(DalComment e) { _context.Comments.Add(e.ToOrmComment()); }
public void Create(DalComment entity) { _context.Set <Comment>().Add(entity.ToOrmComment()); }