示例#1
0
            /// <summary>
            /// Get topics info.
            /// </summary>
            /// <param name="request">Info request.</param>
            /// <param name="cancellationToken">Cancellation token.</param>
            /// <returns>Number of posts DTO.</returns>
            public async Task <IEnumerable <TopicDTO> > Handle(GetTopicsQuery request, CancellationToken cancellationToken)
            {
                var entities = await _context.Topics.ToArrayAsync(cancellationToken);

                var topics = _mapper.Map <IEnumerable <TopicDTO> >(entities);

                return(topics);
            }
示例#2
0
 public TopicsController(TeamCommunicationDbContext context)
 {
     _context     = context;
     this.factory = new DbContextFactory();
     repo         = new TopicRepository(factory);
     commRepo     = new CommentRepository(factory);
     query        = new GetTopicsQuery(factory.CreateDbContext);
     facade       = new TopicFacade(repo, query);
 }
示例#3
0
        public async Task <IActionResult> Create()
        {
            var topicsQuery = new GetTopicsQuery();
            var topicsDTO   = await _mediator.Send(topicsQuery);

            var topics = _mapper.Map <IEnumerable <TopicDTO>, ICollection <TopicViewModel> >(topicsDTO);

            var model = new CreatePostViewModel {
                Topics = topics
            };

            return(View(model));
        }
        public async Task Handler_ReturnsPostDTOCollection()
        {
            // Arrange
            var query = new GetTopicsQuery();

            // Act
            var handler = new GetTopicsQuery.GetTopicsQueryHandler(Context, Mapper);
            var result  = await handler.Handle(query, CancellationToken.None);

            // Assert
            result.ShouldBeOfType <List <TopicDTO> >();
            result.ShouldNotBeNull();
        }
示例#5
0
 public TopicFacade(TopicRepository repository, GetTopicsQuery query)
 {
     this.repository = repository;
     this.query      = query;
 }
示例#6
0
 public async Task <IEnumerable <Topic> > HandleAsync(GetTopicsQuery query)
 {
     return(await Task.FromResult(_context.Topics));
 }