public async Task <IActionResult> GetInstantMessageHistoryForParticipantAsync(Guid conferenceId, string participantUsername)
        {
            _logger.LogDebug("Retrieving instant message history");
            var query = new GetInstantMessagesForConferenceQuery(conferenceId, participantUsername);

            return(await GetInstantMessageHistoryAsync(query));
        }
        public async Task <IActionResult> GetInstantMessageHistoryAsync(Guid conferenceId)
        {
            _logger.LogDebug("Retrieving instant message history");
            var query = new GetInstantMessagesForConferenceQuery(conferenceId, null);

            return(await GetInstantMessageHistoryAsync(query));
        }
예제 #3
0
        public async Task Should_retrieve_all_messages_for_the_participant()
        {
            var conference = new ConferenceBuilder(true)
                             .WithParticipant(UserRole.Individual, "Claimant")
                             .WithParticipant(UserRole.Judge, "Judge")
                             .Build();

            var judge       = conference.GetParticipants().First(x => x.UserRole == UserRole.Judge);
            var participant = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);
            var vhOfficer   = "VH Officer";

            conference.AddInstantMessage(vhOfficer, "InstantMessage 1", judge.DisplayName);
            conference.AddInstantMessage(judge.DisplayName, "InstantMessage 2", vhOfficer);

            conference.AddInstantMessage(participant.Username, "Hello VHO", vhOfficer);
            conference.AddInstantMessage(vhOfficer, "Hello ParticipantOne", participant.Username);

            var seededConference = await TestDataManager.SeedConference(conference);

            _newConferenceId = seededConference.Id;

            var query   = new GetInstantMessagesForConferenceQuery(_newConferenceId, participant.Username);
            var results = await _handler.Handle(query);

            results.Count.Should().Be(conference.GetInstantMessageHistoryFor(participant.Username).Count);
            results.Should().BeInDescendingOrder(x => x.TimeStamp);
        }
        private async Task <IActionResult> GetInstantMessageHistoryAsync(GetInstantMessagesForConferenceQuery query)
        {
            _logger.LogDebug("Retrieving instant message history");
            try
            {
                var messages =
                    await _queryHandler.Handle <GetInstantMessagesForConferenceQuery, List <InstantMessage> >(query);

                var response = messages.Select(InstantMessageToResponseMapper.MapMessageToResponse);
                return(Ok(response));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Unable to find instant messages");
                return(NotFound());
            }
        }