/// <summary> /// Query handler. /// </summary> /// <param name="request"><see cref="GetPartnersQuery"/> request.</param> /// <param name="cancellationToken">Cancellation token.</param> /// <returns>All partners.</returns> public async Task <IEnumerable <Partner> > Handle(GetPartnersQuery request, CancellationToken cancellationToken) { var result = await _context.Partners.Include(partner => partner.Image) .ToListAsync(cancellationToken); return(result); }
public async Task <List <PartnerListViewModel> > Handle(GetPartnersQuery request, CancellationToken cancellationToken) { return(await DataContext.Partners .Include(m => m.EventPartners) .Select(m => new PartnerListViewModel { Id = m.Id, Name = m.Name, EventsCount = m.EventPartners.Count(), IsActive = m.IsActive }).ToListAsync(cancellationToken)); }
public async Task <IEnumerable <Partner> > GetAllPartners([FromQuery] GetPartnersQuery query, CancellationToken cancellationToken) { return(await _mediator.Send(query, cancellationToken)); }