示例#1
0
        private async Task <Guid> CreateConferenceAsync(BookNewConferenceRequest request, string ingestUrl)
        {
            var existingConference = await _queryHandler.Handle <CheckConferenceOpenQuery, Conference>(
                new CheckConferenceOpenQuery(request.ScheduledDateTime, request.CaseNumber, request.CaseName));

            if (existingConference != null)
            {
                return(existingConference.Id);
            }

            var participants = request.Participants.Select(x =>
                                                           new Participant(x.ParticipantRefId, x.Name, x.FirstName, x.LastName, x.DisplayName, x.Username,
                                                                           x.UserRole, x.HearingRole, x.CaseTypeGroup, x.ContactEmail, x.ContactTelephone)
            {
                Representee = x.Representee
            })
                               .ToList();

            var endpoints = request.Endpoints
                            .Select(x => new Endpoint(x.DisplayName, x.SipAddress, x.Pin, x.DefenceAdvocate)).ToList();

            var createConferenceCommand = new CreateConferenceCommand
                                          (
                request.HearingRefId, request.CaseType, request.ScheduledDateTime, request.CaseNumber,
                request.CaseName, request.ScheduledDuration, participants, request.HearingVenueName,
                request.AudioRecordingRequired, ingestUrl, endpoints
                                          );

            await _commandHandler.Handle(createConferenceCommand);

            return(createConferenceCommand.NewConferenceId);
        }
示例#2
0
 public void Handle(CreateConferenceCommand createConferenceCommand)
 {
     Id          = createConferenceCommand.Id;
     AccessCode  = createConferenceCommand.AccessCode;
     Name        = createConferenceCommand.Name;
     Description = createConferenceCommand.Description;
     StartDate   = createConferenceCommand.StartDate;
     FinishDate  = createConferenceCommand.FinishDate;
     Organizer   = new ConferenceOrganizer(createConferenceCommand.OwnerName, createConferenceCommand.OwnerEmail);
     Venue       = createConferenceCommand.Venue;
 }
示例#3
0
        public IActionResult Create([FromBody] CreateRequestModel createRequestModel)
        {
            CreateConferenceCommand command = mapper.Map <CreateConferenceCommand>(createRequestModel);

            createConferenceCommandHandler.Handle(command);

            CreateResponseModel response = new CreateResponseModel {
                Id = command.Id
            };

            return(Created($"api/details/{command.AccessCode}", response));
        }
示例#4
0
        public void Should_throw_participant_link_exception_when_id_doesnt_match()
        {
            var          hearingRefId      = Guid.NewGuid();
            const string caseType          = "Generic";
            var          scheduledDateTime = DateTime.Today.AddDays(1).AddHours(10).AddMinutes(30);
            const string caseNumber        = "AutoTest Create Command 1234";
            const string caseName          = "AutoTest vs Manual Test";
            const int    scheduledDuration = 120;

            var participantA = new ParticipantBuilder(true).Build();
            var participantB = new ParticipantBuilder(true).Build();

            var fakeIdA = Guid.NewGuid();
            var fakeIdB = Guid.NewGuid();

            var linkedParticipants = new List <LinkedParticipantDto>()
            {
                new LinkedParticipantDto()
                {
                    ParticipantRefId = fakeIdA, LinkedRefId = participantB.ParticipantRefId, Type = LinkedParticipantType.Interpreter.MapToDomainEnum()
                },
                new LinkedParticipantDto()
                {
                    ParticipantRefId = fakeIdB, LinkedRefId = participantA.ParticipantRefId, Type = LinkedParticipantType.Interpreter.MapToDomainEnum()
                }
            };

            var participants = new List <Participant>()
            {
                participantA, participantB
            };

            const string hearingVenueName       = "MyVenue";
            const string ingestUrl              = "https://localhost/ingesturl";
            const bool   audioRecordingRequired = true;
            var          endpoints              = new List <Endpoint>
            {
                new Endpoint("name1", GetSipAddress(), "1234", "Defence Sol"),
                new Endpoint("name2", GetSipAddress(), "5678", "Defence Old")
            };

            var command =
                new CreateConferenceCommand(hearingRefId, caseType, scheduledDateTime, caseNumber, caseName,
                                            scheduledDuration, participants, hearingVenueName, audioRecordingRequired, ingestUrl, endpoints, linkedParticipants);

            var exception = Assert.ThrowsAsync <ParticipantLinkException>(() => _handler.Handle(command));

            exception.LinkRefId.Should().Be(participantB.ParticipantRefId);
            exception.ParticipantRefId.Should().Be(fakeIdA);
        }
示例#5
0
        public async Task <CommandResult <int> > CreateConference(CreateConferenceCommand cmd)
        {
            var conferences = await _db.Conferences.ToListAsync();

            if (conferences.Any(x => x.Date.Year == cmd.Date.Year))
            {
                return(CommandResult <int> .Duplicate(cmd, $"Conference already exists for year {cmd.Date.Year}"));
            }

            var conference = new Conference
            {
                Name = cmd.Name,
                Date = cmd.Date,
            };
            var entity = _db.Conferences.Add(conference);
            await _db.SaveChangesAsync();

            return(CommandResult <int> .Success(cmd, entity.Entity.Id));
        }
        public async Task Should_save_new_conference()
        {
            var          hearingRefId      = Guid.NewGuid();
            const string caseType          = "Civil Money Claims";
            var          scheduledDateTime = DateTime.Today.AddDays(1).AddHours(10).AddMinutes(30);
            const string caseNumber        = "AutoTest Create Command 1234";
            const string caseName          = "AutoTest vs Manual Test";
            const int    scheduledDuration = 120;
            var          participant       = new ParticipantBuilder(true).Build();
            var          participants      = new List <Participant> {
                participant
            };
            const string hearingVenueName       = "MyVenue";
            const string ingestUrl              = "https://localhost/ingesturl";
            const bool   audioRecordingRequired = true;
            var          endpoints              = new List <Endpoint>
            {
                new Endpoint("name1", "0987654321", "1234", "Defence Sol"),
                new Endpoint("name2", "1234567890", "5678", "Defence Old")
            };

            var command =
                new CreateConferenceCommand(hearingRefId, caseType, scheduledDateTime, caseNumber, caseName,
                                            scheduledDuration, participants, hearingVenueName, audioRecordingRequired, ingestUrl, endpoints);

            await _handler.Handle(command);

            command.NewConferenceId.Should().NotBeEmpty();
            command.HearingRefId.Should().Be(hearingRefId);
            command.CaseType.Should().Be(caseType);
            command.ScheduledDateTime.Should().Be(scheduledDateTime);
            command.CaseNumber.Should().Be(caseNumber);
            command.CaseName.Should().Be(caseName);
            command.ScheduledDuration.Should().Be(scheduledDuration);
            command.HearingVenueName.Should().Be(hearingVenueName);
            command.AudioRecordingRequired.Should().Be(audioRecordingRequired);
            command.IngestUrl.Should().Be(ingestUrl);
            command.Participants.Should().NotBeNullOrEmpty();
            command.Participants.Count.Should().Be(1);
            command.Participants[0].Should().BeEquivalentTo(participant);
            _newConferenceId = command.NewConferenceId;
        }
 public async Task CreateConference([FromBody] CreateConference input)
 {
     var createConferenceCommand = new CreateConferenceCommand(Guid.NewGuid(), input.ConferenceName, input.ConferenceContent, input.ConferenceAddress, input.ConferenceParticipantNum, input.ConferenceStartTime, input.ConferenceEndTime, Guid.NewGuid());
     await _commandService.SendCommandAsync(createConferenceCommand);
 }
 public async Task <IActionResult> CreateConference([FromBody] CreateConferenceCommand command) =>
 await HandleCommandAsync(command, _commandService.CreateConference);
示例#9
0
        public async Task Should_save_new_conference_with_linked_participants()
        {
            var          hearingRefId      = Guid.NewGuid();
            const string caseType          = "Generic";
            var          scheduledDateTime = DateTime.Today.AddDays(1).AddHours(10).AddMinutes(30);
            const string caseNumber        = "AutoTest Create Command 1234";
            const string caseName          = "AutoTest vs Manual Test";
            const int    scheduledDuration = 120;

            var participantA = new ParticipantBuilder(true).Build();
            var participantB = new ParticipantBuilder(true).Build();

            var linkedParticipants = new List <LinkedParticipantDto>()
            {
                new LinkedParticipantDto()
                {
                    ParticipantRefId = participantA.ParticipantRefId, LinkedRefId = participantB.ParticipantRefId, Type = LinkedParticipantType.Interpreter.MapToDomainEnum()
                },
                new LinkedParticipantDto()
                {
                    ParticipantRefId = participantB.ParticipantRefId, LinkedRefId = participantA.ParticipantRefId, Type = LinkedParticipantType.Interpreter.MapToDomainEnum()
                }
            };

            var participants = new List <Participant>()
            {
                participantA, participantB
            };

            const string hearingVenueName       = "MyVenue";
            const string ingestUrl              = "https://localhost/ingesturl";
            const bool   audioRecordingRequired = true;
            var          endpoints              = new List <Endpoint>
            {
                new Endpoint("name1", GetSipAddress(), "1234", "Defence Sol"),
                new Endpoint("name2", GetSipAddress(), "5678", "Defence Old")
            };


            var command =
                new CreateConferenceCommand(hearingRefId, caseType, scheduledDateTime, caseNumber, caseName,
                                            scheduledDuration, participants, hearingVenueName, audioRecordingRequired, ingestUrl, endpoints, linkedParticipants);

            await _handler.Handle(command);

            command.Participants.Should().NotBeNullOrEmpty();
            command.Participants.Count.Should().Be(2);
            command.Participants[0].Should().BeEquivalentTo(participantA);

            _newConferenceId = command.NewConferenceId;

            var conference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId));

            var confParticipants = conference.GetParticipants();
            var linkCount        = confParticipants.Sum(x => x.LinkedParticipants.Count);

            linkCount.Should().Be(2);

            // verify correct links have been added
            var participantAFromContext = confParticipants.Single(x => x.Id == participantA.Id);
            var participantBFromContext = confParticipants.Single(x => x.Id == participantB.Id);

            participantAFromContext.LinkedParticipants.Should().Contain(x => x.LinkedId == participantBFromContext.Id);
            participantBFromContext.LinkedParticipants.Should().Contain(x => x.LinkedId == participantAFromContext.Id);
        }