public PostDto CreatePost(PostDto post, int userId) { var entity = Converter.ToEntity(post); entity.UserId = userId; entity.Date = DateTime.Now; _postsRepository.Save(entity); return(Converter.ToDto(entity)); }
public CommentReadDto CreateComment(CommentCreateDto commentDto, int postId, int userId) { var post = _postsRepository.FindById(postId); var commentEntity = Converter.ToEntity(commentDto); commentEntity.UserId = userId; commentEntity.Date = DateTime.Now; post.Comments.Add(commentEntity); _postsRepository.Persist(); return(Converter.ToDto(commentEntity)); }