public async Task ProcessNewParticipants(Guid hearingId, EditParticipantRequest participant, HearingDetailsResponse hearing,
                                                 Dictionary <string, User> usernameAdIdDict, List <ParticipantRequest> newParticipantList)
        {
            // Add a new participant
            // Map the request except the username
            var newParticipant = NewParticipantRequestMapper.MapTo(participant);

            // Judge is manually created in AD, no need to create one
            if (participant.CaseRoleName == "Judge")
            {
                if (hearing.Participants != null && hearing.Participants.Any(p => p.Username.Equals(participant.ContactEmail)))
                {
                    //If the judge already exists in the database, there is no need to add again.
                    return;
                }

                newParticipant.Username = participant.ContactEmail;
            }
            else
            {
                // Update the request with newly created user details in AD
                var user = await _userAccountService.UpdateParticipantUsername(newParticipant);

                usernameAdIdDict.Add(newParticipant.Username, user);
            }

            _logger.LogDebug("Adding participant {Participant} to hearing {Hearing}",
                             newParticipant.DisplayName, hearingId);
            newParticipantList.Add(newParticipant);
        }
Exemple #2
0
        public void Should_map_all_properties_for_new_participant_request()
        {
            var source = new EditParticipantRequest();

            source.CaseRoleName     = "caserolename";
            source.ContactEmail     = "contactemail";
            source.DisplayName      = "displayname";
            source.FirstName        = "firstname";
            source.LastName         = "lastname";
            source.MiddleNames      = "middle name";
            source.Representee      = "representee";
            source.TelephoneNumber  = "01234567489";
            source.Title            = "mr";
            source.OrganisationName = "organisation";

            var result = NewParticipantRequestMapper.MapTo(source);

            result.CaseRoleName.Should().Be(source.CaseRoleName);
            result.ContactEmail.Should().Be(source.ContactEmail);
            result.DisplayName.Should().Be(source.DisplayName);
            result.FirstName.Should().Be(source.FirstName);
            result.LastName.Should().Be(source.LastName);
            result.HearingRoleName.Should().Be(source.HearingRoleName);
            result.MiddleNames.Should().Be(source.MiddleNames);
            result.Representee.Should().Be(source.Representee);
            result.TelephoneNumber.Should().Be(source.TelephoneNumber);
            result.Title.Should().Be(source.Title);
            result.OrganisationName.Should().Be(source.OrganisationName);
        }