public async Task <List <Conference> > Handle(GetClosedConferencesWithInstantMessagesQuery query) { return(await _context.Conferences .Include(x => x.InstantMessageHistory) .Where(x => x.InstantMessageHistory.Any()) .Where(x => x.State == ConferenceState.Closed && x.ClosedDateTime.HasValue && x.ClosedDateTime.Value.AddMinutes(30) <= DateTime.UtcNow) .AsNoTracking() .ToListAsync()); }
public async Task <IActionResult> GetClosedConferencesWithInstantMessagesAsync() { _logger.LogDebug($"GetClosedConferencesWithInstantMessages"); var query = new GetClosedConferencesWithInstantMessagesQuery(); var closedConferences = await _queryHandler.Handle <GetClosedConferencesWithInstantMessagesQuery, List <Conference> >(query); if (!closedConferences.Any()) { _logger.LogDebug($"No closed conferences with instant messages found."); return(Ok(new List <ClosedConferencesResponse>())); } var response = closedConferences.Select(ConferenceToClosedConferenceMapper.MapConferenceToClosedResponse); return(Ok(response)); }