public PostDetailModelDTO GetPostByComment(CommentDetailModelDTO comment) { using (var connection = chatterDbContextFactory.CreateDbContext()) { return(mapper.MapEntityToDetailModel(connection.Posts.Where(x => x.Comments.Where(y => x.Id == y.Id).FirstOrDefault() != null).FirstOrDefault())); } }
public void Create_WithNonExistingItem_DoesNotThrow() { var model = new CommentDetailModelDTO { Id = new Guid() }; //var returnedModel = fixture.Repository.AddComment(model); Assert.IsNotNull(model); }
public bool RemoveComment(CommentDetailModelDTO comment) { if (comment == null) { return(false); } using (var connection = chatterDbContextFactory.CreateDbContext()) { connection.Comments.Remove(mapper.MapDetailToEntity(comment)); return(connection.SaveChanges() == 1); } }
public Comment MapDetailToEntity(CommentDetailModelDTO comment) { if (comment == null) { return(new Comment()); } return(new Comment() { Content = comment.Content, DateTime = comment.DateTime, Id = comment.Id, User = MapDetailToEntity(comment.User) }); }
public CommentDetailModelDTO AddComment(CommentDetailModelDTO comment) { using (var connection = chatterDbContextFactory.CreateDbContext()) { var newComment = mapper.MapDetailToEntity(comment); connection.Users.Attach(mapper.MapDetailToEntity(comment.User)); var post = connection.Posts.Single(x => x.Id == comment.Post.Id); newComment.Post = post; connection.Posts.Attach(post); connection.Comments.Add(newComment); connection.SaveChanges(); return(mapper.MapEntityToDetailModel(newComment)); } }
public bool EditComment(CommentDetailModelDTO comment) { throw new NotImplementedException(); }