public async Task <ActionResult <Pagination <TicketDto> > > GetAllTickets( [FromQuery] TicketSpecParams parameters) { var query = new GetAllTicketsQuery(parameters); var result = await _mediator.Send(query); return(Ok(result)); }
public async Task <Pagination <TicketDto> > Handle(GetAllTicketsQuery request, CancellationToken cancellationToken) { var spec = new TicketsWithCommentsAndDevelopersSpecification(request.TicketParameters); var countSpec = new TicketWithFiltersForCountSpecification(request.TicketParameters); var tickets = await _unitOfWork.Repository <Ticket>().ListAsync(spec); var totalItems = await _unitOfWork.Repository <Ticket>().CountAsync(countSpec); var data = _mapper.Map <IReadOnlyList <Ticket>, IReadOnlyList <TicketDto> >(tickets); return(new Pagination <TicketDto>(request.TicketParameters.PageIndex, request.TicketParameters.PageSize, totalItems, data)); }
public async Task GivenAList_WhenGetAllTicketsQueryHandler_ThenReturnNotNull() { var ticket1 = TicketsFactory.ValidTicket(); var ticket2 = TicketsFactory.ValidTicket(); var tickets = new List <Ticket> { ticket1, ticket2 }; var command = new GetAllTicketsQuery(); var mockRepo = new Mock <ITicketRepository>(); mockRepo.Setup(db => db.GetAllAsync().Result).Returns(tickets); var handler = new GetAllTicketsQueryHandler(mockRepo.Object); var result = await handler.Handle(command, CancellationToken.None); result.Should().NotContainNulls(); result.Should().HaveCount(tickets.Count); result.Should().Contain(ticket1); }
public async Task <IEnumerable <Ticket> > Handle(GetAllTicketsQuery request, CancellationToken cancellationToken) { return(await _repository.GetAllAsync()); }
public async Task <List <TicketListVm> > Handle(GetAllTicketsQuery request, CancellationToken cancellationToken) { return(await _context.Tickets.OrderByDescending(f => f.Id) .ProjectTo <TicketListVm>(_mapper.ConfigurationProvider).ToListAsync(cancellationToken)); }
public async Task <IEnumerable <Ticket> > Handle(GetAllTicketsQuery request, CancellationToken cancellationToken) { return(appDbContext.Tickets.ToList()); }