public void TestCleanup() { Target = null; MockDatabase = null; MockQuery = null; MockCommentHydrater = null; }
public iNaturalistMapperFactory() { CommentMapper = new CommentMapper(); PhotoMapper = new PhotoMapper(); TaxonMapper = new TaxonMapper(PhotoMapper); IdentificationMapper = new IdentificationMapper(TaxonMapper); UserMapper = new UserMapper(); ObservationMapper = new ObservationMapper(CommentMapper, IdentificationMapper, PhotoMapper, TaxonMapper, UserMapper); }
public void CommentMapTest() { // Arrange var commentMapper = new CommentMapper(); dynamic obj = new JObject(); obj.id = "101"; obj.created_at = "2017-11-20T14:28:53.572+11:00"; obj.body = "Hey!"; var comment = new Comment(); // Act commentMapper.Map(obj, comment); // Assert Assert.AreEqual(comment.Id, 101); Assert.AreEqual(comment.CreatedAt, Convert.ToDateTime("2017-11-20T14:28:53.572+11:00")); Assert.AreEqual(comment.Body, "Hey!"); }
public (CommentDto commentDto, PostDto post) CreateComment(CommentDto commentDto, int?userId) { Post post = _db.Post .Where(p => p.PostId == commentDto.PostId) .Include(p => p.PostType) .FirstOrDefault() ?? throw new PostNotFoundException(); Comment comment = CommentMapper.FromDto(commentDto); comment.UserId = (int)userId; _db.Comment.Add(comment); _db.SaveChanges(); Comment commentWithJoin = _db.Comment .Where(c => c.CommentId == comment.CommentId) .Include(c => c.User) .Include(c => c.CommentType) .First(); return(CommentMapper.ToDto(commentWithJoin, userId), PostMapper.ToDtoPostUrl(post)); }
public ActionResult AlbumComments(string id, string comment) { Guid userID = UserHelper.GetLogedInUser(userRepository).Id; var comm = new Comment { AlbumID = new Guid(id), Date = DateTime.Now, Content = comment, Id = Guid.NewGuid(), UserID = userID }; commentRepository.AddComment(comm); List <Comment> comments = commentRepository.GetAllComentsByAlbumID(id.ToString()).OrderBy(x => x.Date).ToList(); List <CommentViewModel> model = new List <CommentViewModel>(); comments.ForEach(x => model.Add(CommentMapper.MapCommentViewModel(x))); return(Json(model)); }
private PostDto MapReceivedPost(Post postMapFrom) { var postMapper = new PostMapper(); PostDto postDTO = postMapper.MapToPostDto(postMapFrom); if (postMapFrom.RelatedTo != null) { var blogMapper = new BlogMapper(); postDTO.RelatedTo = blogMapper.MapToBlogDto(postMapFrom.RelatedTo); } if (postMapFrom.PostCategories != null) { var categoryMapper = new CategoryMapper(); postDTO.PostCategories = categoryMapper.MapToCategoryDtoList(postMapFrom.PostCategories); } if (postMapFrom.PostComments != null) { var commentMapper = new CommentMapper(); var userMapper = new BlogUserMapper(); var commentDTOList = new List <CommentDto>(); foreach (var comment in postMapFrom.PostComments) { var commentDTOToAdd = commentMapper.MapToCommentDto(comment); if (comment.CreatedBy != null) { commentDTOToAdd.CreatedBy = userMapper.MapToBlogUserDto(comment.CreatedBy); } commentDTOList.Add(commentDTOToAdd); } postDTO.PostComments = commentDTOList; } return(postDTO); }
public ActionResult Delete(CommentViewModel model, FormCollection collection) { var comment = commentRepository.GetCommentByID(model.id); commentRepository.DeleteComment(comment); Guid id; List <CommentViewModel> models = new List <CommentViewModel>(); if (comment.AlbumID == null) { id = (Guid)comment.PhotoID; List <Comment> comments = commentRepository.GetAllComentsByPhotoID(id.ToString()); comments.ForEach(x => models.Add(CommentMapper.MapCommentViewModel(x))); } else { id = (Guid)comment.AlbumID; List <Comment> comments = commentRepository.GetAllComentsByAlbumID(id.ToString()); comments.ForEach(x => models.Add(CommentMapper.MapCommentViewModel(x))); } return(PartialView("_Items", models)); }
public void EntityToListModel_ShouldBeEqual() { var user = new User() { FirstName = "John", LastName = "Doe" }; var model = new Comment() { Author = user, Id = Guid.NewGuid(), Text = "This is a comment!" }; var returned = CommentMapper.EntityToListModel(model); Assert.Equal(model.Author.FirstName, returned.Author.FirstName); Assert.Equal(model.Author.LastName, returned.Author.LastName); Assert.Equal(model.Id, returned.Id); Assert.Equal(model.Timestamp, returned.Timestamp); Assert.IsType <CommentListModel>(returned); }
public void AddComment(int postId, string text, int userId) { var cm = new CommentMapper(); cm.AddComment(postId, text, userId); }
public IEnumerable <Comment> GetPostComments(int postId) { var cm = new CommentMapper(); return(cm.GetPostComments(postId)); }
#pragma warning disable CS1591 // 缺少对公共可见类型或成员“DetailsController.DetailsController(IFileAttachmentService, IArticleService, ITagService, ICommentService, IUserService, ArticleMapper, CommentMapper, EmailHelper)”的 XML 注释 public DetailsController(IFileAttachmentService fileAttachmentService, IArticleService articleService, ITagService tagService, ICommentService commentService, IUserService userService, ArticleMapper articleMapper, CommentMapper commentMapper, EmailHelper emailHelper) #pragma warning restore CS1591 // 缺少对公共可见类型或成员“DetailsController.DetailsController(IFileAttachmentService, IArticleService, ITagService, ICommentService, IUserService, ArticleMapper, CommentMapper, EmailHelper)”的 XML 注释 { this.fileAttachmentService = fileAttachmentService; this.articleService = articleService; this.tagService = tagService; this.commentService = commentService; this.userService = userService; this.articleMapper = articleMapper; this.commentMapper = commentMapper; this.emailHelper = emailHelper; }
public IActionResult GetByReview(int id) { var comments = _work.RepositoryComentarios.GetByCritica(id); return(Ok(CommentMapper.Map(comments))); }
public void TestInitialize() { Target = new CommentMapper(); }
public void TestInitialize() { Target = new CommentMapper(); }
// Setup // The constructor is used as a setup method -> xunit // other testing frameworks might have specific method names // or annotations public CommentMapperTests() { _commentMapper = new CommentMapper(); }
public void TestInitialize() { MockDatabase = new Mock<IDatabase>(); MockQuery = new Mock<IQuery>(); MockCommentHydrater = new Mock<IHydrater<CommentVO>>(); Target = new CommentMapper(MockDatabase.Object, MockCommentHydrater.Object); }
public override async Task <Comment> FindAsync(params object[] id) { return(CommentMapper.MapFromDAL(await Uow.Comments.FindAsync(id))); }
public CommentsController(ICommentProvider commentProvider, CommentMapper commentMapper) { _commentProvider = commentProvider; _commentMapper = commentMapper; }
public override async Task <List <Comment> > AllAsync() { return((await Uow.Comments.AllAsync()).Select(e => CommentMapper.MapFromDAL(e)).ToList()); }
public async Task <ActionResult <IEnumerable <PublicApi.v1.DTO.Comment> > > GetComments(string search, int?pageIndex, int?pageSize) { if ((pageIndex != null && pageIndex < 1) || (pageSize != null && pageSize < 1)) { return(BadRequest()); } //var comment = await _bll.Comments.AllAsync(); var comment = (await _bll.Comments.GetAllWithProductByShopAsync(User.GetShopId(), search, pageIndex, pageSize)).Select(e => CommentMapper.MapFromBLL(e)).ToList(); return(comment); }
public CommentController(ICommentService commentService, CommentMapper commentMapper) { _commentService = commentService; _commentMapper = commentMapper; }
public void Setup() { _mapper = new CommentMapper(); }
public async Task <List <DTO.Comment> > GetAllWithProductByShopAsync(int?shopId, string search, int?pageIndex, int?pageSize) { return((await Uow.Comments.GetAllWithProductByShopAsync(shopId, search, pageIndex, pageSize)).Select(e => CommentMapper.MapFromDAL(e)).ToList()); }
public IActionResult Get() { var comments = _work.RepositoryComentarios.GetAll().ToList(); return(Ok(CommentMapper.Map(comments))); }
public async Task <List <Comment> > AllAsync(string order, string searchFor, int?pageIndex, int?pageSize) { return((await Uow.Comments.AllAsync(order, searchFor, pageIndex, pageSize)).Select(e => CommentMapper.MapFromDAL(e)).ToList()); }
public void TestCleanup() { Target = null; }
public IActionResult GetPaginatedCrit(int idRew, int page, int rows) { var comments = _work.RepositoryComentarios.GetPaginated(idRew, page, rows).ToList(); return(Ok(CommentMapper.Map(comments))); }
public async Task <DTO.Comment> GetCommentById(int id) { return(CommentMapper.MapFromDAL(await Uow.Comments.GetCommentById(id))); }
public void TestCleanup() { Target = null; }
public async Task <DTO.Comment> GetCommentByIdAndShop(int id, int?shopId) { return(CommentMapper.MapFromDAL(await Uow.Comments.GetCommentByIdAndShop(id, shopId))); }
public CommentEntity() { mapper = new CommentMapper(); }