/// <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); }
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); }
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(); }
public TopicFacade(TopicRepository repository, GetTopicsQuery query) { this.repository = repository; this.query = query; }
public async Task <IEnumerable <Topic> > HandleAsync(GetTopicsQuery query) { return(await Task.FromResult(_context.Topics)); }