コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: GetPartnersQuery.cs プロジェクト: mentortori/Gram
 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));
 }
コード例 #3
0
 public async Task <IEnumerable <Partner> > GetAllPartners([FromQuery] GetPartnersQuery query, CancellationToken cancellationToken)
 {
     return(await _mediator.Send(query, cancellationToken));
 }