예제 #1
0
 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);
 }
예제 #3
0
        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!");
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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);
        }
예제 #7
0
        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));
        }
예제 #8
0
        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);
        }
예제 #9
0
        public void AddComment(int postId, string text, int userId)
        {
            var cm = new CommentMapper();

            cm.AddComment(postId, text, userId);
        }
예제 #10
0
        public IEnumerable <Comment> GetPostComments(int postId)
        {
            var cm = new CommentMapper();

            return(cm.GetPostComments(postId));
        }
예제 #11
0
#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;
        }
예제 #12
0
        public IActionResult GetByReview(int id)
        {
            var comments = _work.RepositoryComentarios.GetByCritica(id);

            return(Ok(CommentMapper.Map(comments)));
        }
예제 #13
0
 public void TestInitialize()
 {
     Target = new CommentMapper();
 }
예제 #14
0
 public void TestInitialize()
 {
     Target = new CommentMapper();
 }
예제 #15
0
 // 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();
 }
예제 #16
0
        public void TestInitialize()
        {
            MockDatabase = new Mock<IDatabase>();
            MockQuery = new Mock<IQuery>();
            MockCommentHydrater = new Mock<IHydrater<CommentVO>>();

            Target = new CommentMapper(MockDatabase.Object, MockCommentHydrater.Object);
        }
예제 #17
0
 public override async Task <Comment> FindAsync(params object[] id)
 {
     return(CommentMapper.MapFromDAL(await Uow.Comments.FindAsync(id)));
 }
예제 #18
0
 public CommentsController(ICommentProvider commentProvider, CommentMapper commentMapper)
 {
     _commentProvider = commentProvider;
     _commentMapper   = commentMapper;
 }
예제 #19
0
 public override async Task <List <Comment> > AllAsync()
 {
     return((await Uow.Comments.AllAsync()).Select(e => CommentMapper.MapFromDAL(e)).ToList());
 }
예제 #20
0
        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);
        }
예제 #21
0
 public CommentController(ICommentService commentService, CommentMapper commentMapper)
 {
     _commentService = commentService;
     _commentMapper  = commentMapper;
 }
 public void Setup()
 {
     _mapper = new CommentMapper();
 }
예제 #23
0
 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());
 }
예제 #24
0
        public IActionResult Get()
        {
            var comments = _work.RepositoryComentarios.GetAll().ToList();

            return(Ok(CommentMapper.Map(comments)));
        }
예제 #25
0
 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());
 }
예제 #26
0
 public void TestCleanup()
 {
     Target = null;
 }
예제 #27
0
        public IActionResult GetPaginatedCrit(int idRew, int page, int rows)
        {
            var comments = _work.RepositoryComentarios.GetPaginated(idRew, page, rows).ToList();

            return(Ok(CommentMapper.Map(comments)));
        }
예제 #28
0
 public async Task <DTO.Comment> GetCommentById(int id)
 {
     return(CommentMapper.MapFromDAL(await Uow.Comments.GetCommentById(id)));
 }
예제 #29
0
 public void TestCleanup()
 {
     Target = null;
 }
예제 #30
0
 public async Task <DTO.Comment> GetCommentByIdAndShop(int id, int?shopId)
 {
     return(CommentMapper.MapFromDAL(await Uow.Comments.GetCommentByIdAndShop(id, shopId)));
 }
예제 #31
0
 public CommentEntity()
 {
     mapper = new CommentMapper();
 }