public static ParticipantResponse MapParticipantToResponseModel(ParticipantDetailsResponse participant)
        {
            var status = Enum.Parse <ParticipantStatus>(participant.Current_status.ToString());
            var role   = Enum.Parse <Role>(participant.User_role.ToString());

            var response = new ParticipantResponse
            {
                Id            = participant.Id,
                Name          = participant.Name,
                Status        = status,
                Role          = role,
                Username      = participant.Username,
                DisplayName   = participant.Display_name,
                CaseTypeGroup = participant.Case_type_group,
                Representee   = participant.Representee,
                FirstName     = participant.First_name,
                LastName      = participant.Last_name,
                HearingRole   = participant.Hearing_role
            };

            if (role == Role.Judge)
            {
                response.TiledDisplayName = $"T{0};{participant.Display_name};{participant.Id}";
            }

            return(response);
        }
Esempio n. 2
0
 private static void AssertRepresentativeResponse(ParticipantResponse response, Representative representative)
 {
     if (representative == null)
     {
         response.Representee.Should().BeNullOrWhiteSpace();
     }
     else
     {
         response.Representee.Should().Be(representative.Representee);
     }
 }
        private bool HasExistingLink(LinkedParticipant linkedParticipantInRequest, ParticipantResponse participant)
        {
            var linkedId     = linkedParticipantInRequest.LinkedId;
            var existingLink = false;

            if (participant.LinkedParticipants != null)
            {
                existingLink = participant.LinkedParticipants.Exists(x => x.LinkedId == linkedId);
            }

            return(existingLink);
        }
        public static AddNotificationRequest MapToHearingAmendmentNotification(HearingDetailsResponse hearing,
                                                                               ParticipantResponse participant, string caseName, string caseNumber, DateTime originalDateTime,
                                                                               DateTime newDateTime)
        {
            var parameters = new Dictionary <string, string>
            {
                { "case name", caseName },
                { "case number", caseNumber },
                { "Old time", originalDateTime.ToEmailTimeGbLocale() },
                { "New time", newDateTime.ToEmailTimeGbLocale() },
                { "Old Day Month Year", originalDateTime.ToEmailDateGbLocale() },
                { "New Day Month Year", newDateTime.ToEmailDateGbLocale() }
            };

            NotificationType notificationType;

            if (participant.UserRoleName.Contains("Judge", StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingAmendmentJudge;
                parameters.Add("judge", participant.DisplayName);
                parameters.Add("courtroom account username", participant.Username);
                participant.ContactEmail    = hearing.GetJudgeEmail();
                participant.TelephoneNumber = hearing.GetJudgePhone();
            }
            else if (participant.UserRoleName.Contains("Judicial Office Holder",
                                                       StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingAmendmentJoh;
                parameters.Add("judicial office holder", $"{participant.FirstName} {participant.LastName}");
            }
            else if (participant.UserRoleName.Contains("Representative", StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingAmendmentRepresentative;
                parameters.Add("client name", participant.Representee);
                parameters.Add("solicitor name", $"{participant.FirstName} {participant.LastName}");
            }
            else
            {
                notificationType = NotificationType.HearingAmendmentLip;
                parameters.Add("name", $"{participant.FirstName} {participant.LastName}");
            }

            return(new AddNotificationRequest
            {
                HearingId = hearing.Id,
                MessageType = MessageType.Email,
                ContactEmail = participant.ContactEmail,
                NotificationType = notificationType,
                ParticipantId = participant.Id,
                PhoneNumber = participant.TelephoneNumber,
                Parameters = parameters
            });
        }
        public static AddNotificationRequest MapToMultiDayHearingConfirmationNotification(
            HearingDetailsResponse hearing,
            ParticipantResponse participant, int days)
        {
            var @case           = hearing.Cases.First();
            var cleanedCaseName = @case.Name.Replace($"Day 1 of {days}", string.Empty).Trim();
            var parameters      = new Dictionary <string, string>
            {
                { "case name", cleanedCaseName },
                { "case number", @case.Number },
                { "time", hearing.ScheduledDateTime.ToEmailTimeGbLocale() },
                { "Start Day Month Year", hearing.ScheduledDateTime.ToEmailDateGbLocale() },
                { "number of days", days.ToString() }
            };
            NotificationType notificationType;

            if (participant.UserRoleName.Contains("Judge", StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingConfirmationJudgeMultiDay;
                parameters.Add("judge", participant.DisplayName);
                parameters.Add("courtroom account username", participant.Username);
                participant.ContactEmail    = hearing.GetJudgeEmail();
                participant.TelephoneNumber = hearing.GetJudgePhone();
            }
            else if (participant.UserRoleName.Contains("Judicial Office Holder",
                                                       StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingConfirmationJohMultiDay;
                parameters.Add("judicial office holder", $"{participant.FirstName} {participant.LastName}");
            }
            else if (participant.UserRoleName.Contains("Representative", StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingConfirmationRepresentativeMultiDay;
                parameters.Add("client name", participant.Representee);
                parameters.Add("solicitor name", $"{participant.FirstName} {participant.LastName}");
            }
            else
            {
                notificationType = NotificationType.HearingConfirmationLipMultiDay;
                parameters.Add("name", $"{participant.FirstName} {participant.LastName}");
            }

            return(new AddNotificationRequest
            {
                HearingId = hearing.Id,
                MessageType = MessageType.Email,
                ContactEmail = participant.ContactEmail,
                NotificationType = notificationType,
                ParticipantId = participant.Id,
                PhoneNumber = participant.TelephoneNumber,
                Parameters = parameters
            });
        }
 private void VerifyParticipant(ParticipantResponse participant)
 {
     _browsers[_c.CurrentUser].TextOf(BookingDetailsPage.ParticipantName(participant.Id)).Should().Contain($"{_c.Test.TestData.AddParticipant.Participant.Title} {participant.FirstName} {participant.LastName}");
     if (participant.UserRoleName.Equals("Representative"))
     {
         _browsers[_c.CurrentUser].TextOf(BookingDetailsPage.ParticipantRepresentee(participant.Id)).Should().Be(participant.Representee);
     }
     else
     {
         _browsers[_c.CurrentUser].TextOf(BookingDetailsPage.ParticipantRole(participant.Id)).Should().Be(participant.HearingRoleName);
     }
     _browsers[_c.CurrentUser].TextOf(BookingDetailsPage.ParticipantPhone(participant.Id)).Should().Be(participant.TelephoneNumber);
 }
Esempio n. 7
0
 public static Participant MapParticipant(MatchResponse matchData, ParticipantResponse participant, ParticipantStat stats)
 {
     return(new Participant
     {
         MatchId = matchData.MatchId,
         ChampionId = participant.ChampionId,
         HighestAchievedSeasonTier = participant.HighestAchievedSeasonTier,
         ParticipantId = participant.ParticipantId,
         ParticipantStat = stats,
         Spell1Id = participant.Spell1Id,
         Spell2Id = participant.Spell2Id,
         TeamId = participant.TeamId
     });
 }
        public static AddNotificationRequest MapToHearingConfirmationNotification(HearingDetailsResponse hearing,
                                                                                  ParticipantResponse participant)
        {
            var parameters = InitConfirmReminderParams(hearing);

            NotificationType notificationType;

            if (participant.UserRoleName.Contains("Judge", StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingConfirmationJudge;
                parameters.Add("judge", participant.DisplayName);
                parameters.Add("courtroom account username", participant.Username);
                participant.ContactEmail    = hearing.GetJudgeEmail();
                participant.TelephoneNumber = hearing.GetJudgePhone();
            }
            else if (participant.UserRoleName.Contains("Judicial Office Holder",
                                                       StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingConfirmationJoh;
                parameters.Add("judicial office holder", $"{participant.FirstName} {participant.LastName}");
            }
            else if (participant.UserRoleName.Contains("Representative", StringComparison.InvariantCultureIgnoreCase))
            {
                notificationType = NotificationType.HearingConfirmationRepresentative;
                parameters.Add("client name", participant.Representee);
                parameters.Add("solicitor name", $"{participant.FirstName} {participant.LastName}");
            }
            else
            {
                notificationType = NotificationType.HearingConfirmationLip;
                parameters.Add("name", $"{participant.FirstName} {participant.LastName}");
            }

            return(new AddNotificationRequest
            {
                HearingId = hearing.Id,
                MessageType = MessageType.Email,
                ContactEmail = participant.ContactEmail,
                NotificationType = notificationType,
                ParticipantId = participant.Id,
                PhoneNumber = participant.TelephoneNumber,
                Parameters = parameters
            });
        }
Esempio n. 9
0
        public static Domain.Member.Member ToMember(this ParticipantResponse response)
        {
            var member = new Domain.Member.Member();

            if (response != null)
            {
                member.Id           = response.Id;
                member.Email        = response.Email;
                member.Role         = response.Role;
                member.IsAfk        = response.IsAfk;
                member.IsBanned     = response.IsBanned;
                member.LastActivity = response.LastActivity;
                member.LastNudged   = response.LastNudged;
                member.SaasUserId   = response.SaasUserId;
                member.Name         = response.UserName;
                member.Status       = response.Status;
            }
            return(member);
        }
Esempio n. 10
0
        public static ParticipantResponse ToParticipantResponse(this Domain.Member.Member member)
        {
            var participant = new ParticipantResponse();

            if (member != null)
            {
                participant.Id           = member.Id;
                participant.Email        = member.Email;
                participant.Role         = member.Role;
                participant.IsAfk        = member.IsAfk;
                participant.IsBanned     = member.IsBanned;
                participant.LastActivity = member.LastActivity;
                participant.LastNudged   = member.LastNudged;
                participant.SaasUserId   = member.SaasUserId;
                participant.UserName     = member.Name;
                participant.Status       = member.Status;
            }
            return(participant);
        }
 private static void AssertAddressMapping(ParticipantResponse response, Person person)
 {
     if (person == null)
     {
         response.HouseNumber.Should().BeNullOrWhiteSpace();
         response.Street.Should().BeNullOrWhiteSpace();
         response.Postcode.Should().BeNullOrWhiteSpace();
         response.City.Should().BeNullOrWhiteSpace();
         response.County.Should().BeNullOrWhiteSpace();
     }
     else
     {
         response.HouseNumber.Should().Be(person.Address.HouseNumber);
         response.Street.Should().Be(person.Address.Street);
         response.Postcode.Should().Be(person.Address.Postcode);
         response.City.Should().Be(person.Address.City);
         response.County.Should().Be(person.Address.County);
     }
 }
        private static void AssertParticipantCommonDetails(ParticipantResponse response, Participant participant,
                                                           CaseRole caseRole, HearingRole hearingRole)
        {
            response.Id.Should().Be(participant.Id);
            response.DisplayName.Should().Be(participant.DisplayName);
            response.CaseRoleName.Should().Be(caseRole.Name);
            response.HearingRoleName.Should().Be(hearingRole.Name);
            response.UserRoleName.Should().Be(hearingRole.UserRole.Name);

            var person = participant.Person;

            response.Title.Should().Be(person.Title);
            response.FirstName.Should().Be(person.FirstName);
            response.MiddleNames.Should().Be(person.MiddleNames);
            response.LastName.Should().Be(person.LastName);

            response.ContactEmail.Should().Be(person.ContactEmail);
            response.TelephoneNumber.Should().Be(person.TelephoneNumber);
            response.Username.Should().Be(person.Username);
        }
Esempio n. 13
0
        public void Should_map_properties_for_notification_request_for_representative()
        {
            var hearingId     = Guid.NewGuid();
            var participantId = Guid.NewGuid();
            var firstName     = "firstname";
            var lastName      = "lastname";
            var userName      = "******";
            var password      = "******";

            var parameters = new Dictionary <string, string>
            {
                { "name", $"{firstName} {lastName}" },
                { "username", $"{userName}" },
                { "random password", $"{password}" }
            };

            var source = new ParticipantResponse
            {
                Id              = participantId,
                Username        = userName,
                CaseRoleName    = "caserolename",
                ContactEmail    = "*****@*****.**",
                FirstName       = firstName,
                HearingRoleName = "hearingrolename",
                LastName        = lastName,
                TelephoneNumber = "0123456789",
                UserRoleName    = "Representative"
            };

            var result = AddNotificationRequestMapper.MapToNewUserNotification(hearingId, source, password);

            result.Should().NotBeNull();
            result.HearingId.Should().Be(hearingId);
            result.ParticipantId.Should().Be(participantId);
            result.ContactEmail.Should().Be(source.ContactEmail);
            result.NotificationType.Should().Be(NotificationType.CreateRepresentative);
            result.MessageType.Should().Be(MessageType.Email);
            result.PhoneNumber.Should().Be(source.TelephoneNumber);
            result.Parameters.Should().BeEquivalentTo(parameters);
        }
        public ParticipantResponse MapParticipantToResponse(Participant participant)
        {
            var participantResponse = new ParticipantResponse
            {
                Id              = participant.Id,
                DisplayName     = participant.DisplayName,
                CaseRoleName    = participant.CaseRole.Name,
                HearingRoleName = participant.HearingRole.Name,
                UserRoleName    = participant.HearingRole.UserRole.Name,
                Title           = participant.Person.Title,
                FirstName       = participant.Person.FirstName,
                LastName        = participant.Person.LastName,
                MiddleNames     = participant.Person.MiddleNames,
                Username        = participant.Person.Username,
                ContactEmail    = participant.Person.ContactEmail,
                TelephoneNumber = participant.Person.TelephoneNumber,
                HouseNumber     = participant.Person.Address?.HouseNumber,
                Street          = participant.Person.Address?.Street,
                City            = participant.Person.Address?.City,
                County          = participant.Person.Address?.County,
                Postcode        = participant.Person.Address?.Postcode,
                Organisation    = participant.Person.Organisation?.Name
            };

            switch (participant.HearingRole.UserRole.Name)
            {
            case "Representative":
                var representative = (Representative)participant;
                participantResponse.Reference   = representative.Reference;
                participantResponse.Representee = representative.Representee;
                break;

            case "Individual":
            case "Judge":
                break;
            }

            return(participantResponse);
        }
Esempio n. 15
0
        public ParticipantResponse MapParticipantToResponse(Participant participant)
        {
            var participantResponse = new ParticipantResponse
            {
                Id                 = participant.Id,
                DisplayName        = participant.DisplayName,
                CaseRoleName       = participant.CaseRole.Name,
                HearingRoleName    = participant.HearingRole.Name,
                UserRoleName       = participant.HearingRole.UserRole.Name,
                Title              = participant.Person.Title,
                FirstName          = participant.Person.FirstName,
                LastName           = participant.Person.LastName,
                MiddleNames        = participant.Person.MiddleNames,
                Username           = participant.Person.Username,
                ContactEmail       = participant.Person.ContactEmail,
                TelephoneNumber    = participant.Person.TelephoneNumber,
                Organisation       = participant.Person.Organisation?.Name,
                LinkedParticipants = participant.LinkedParticipants.Select(x => new LinkedParticipantResponse
                {
                    LinkedId = x.LinkedId, Type = x.Type.MapToContractEnum()
                }).ToList()
            };

            switch (participant.HearingRole.UserRole.Name)
            {
            case "Representative":
                var representative = (Representative)participant;
                participantResponse.Representee = representative.Representee;
                break;

            case "Individual":
            case "Judge":
            case "StaffMember":
            case "JudicialOfficeHolder":
                break;
            }

            return(participantResponse);
        }
Esempio n. 16
0
 private static string GetTiledDisplayName(ParticipantResponse participant, string prefix)
 {
     return($"{prefix};{participant.DisplayName};{participant.Id}");
 }
Esempio n. 17
0
        private void TheToolTipDetailsAreDisplayed(ParticipantDetailsResponse participant, ParticipantResponse hearingParticipant)
        {
            var participantEmailAndRole = $"{participant.Name} ({participant.Case_type_group})";

            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(VhoHearingListPage.ParticipantContactName(participant.Id)).Text.Trim().Should().Be(participantEmailAndRole);
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(VhoHearingListPage.ParticipantContactEmail(participant.Id)).Text.Trim().Should().Be(hearingParticipant.Contact_email);
            _browsers[_c.CurrentUser].Driver.WaitUntilVisible(VhoHearingListPage.ParticipantContactPhone(participant.Id)).Text.Trim().Should().Be(hearingParticipant.Telephone_number);
        }
 private void VerifyJudgeDetails(ParticipantResponse participant)
 {
     _browsers[_c.CurrentUser].TextOf(BookingDetailsPage.JudgeName).Should().Contain(participant.DisplayName);
     _browsers[_c.CurrentUser].TextOf(BookingDetailsPage.JudgeRole).Should().Be(participant.UserRoleName);
 }
Esempio n. 19
0
        /// <summary>
        /// This is the method used when submitting a survey into the database in both the SubmittedSurvey and ParticipantResponse tables
        /// </summary>
        /// <param name="survey_version_id_param"></param>
        /// <param name="unit_id_param"></param>
        /// <param name="meal_id_param"></param>
        /// <param name="participant_type_id_param"></param>
        /// <param name="age_range_id_param"></param>
        /// <param name="gender_id_param"></param>
        /// <param name="contact_request_param"></param>
        /// <param name="contact_room_number_param"></param>
        /// <param name="contact_phone_number_param"></param>
        /// <param name="Q1AResponse_param"></param>
        /// <param name="Q1BResponse_param"></param>
        /// <param name="Q1CResponse_param"></param>
        /// <param name="Q1DResponse_param"></param>
        /// <param name="Q1EResponse_param"></param>
        /// <param name="Q2Response_param"></param>
        /// <param name="Q3Response_param"></param>
        /// <param name="Q4Response_param"></param>
        /// <param name="Q5Response_param"></param>
        public void SubmitSurvey(int survey_version_id_param, int unit_id_param, int meal_id_param, int participant_type_id_param, int age_range_id_param,
                                 int gender_id_param, bool contact_request_param, string contact_room_number_param, string contact_phone_number_param, string Q1AResponse_param,
                                 string Q1BResponse_param, string Q1CResponse_param, string Q1DResponse_param, string Q1EResponse_param, string Q2Response_param, string Q3Response_param,
                                 string Q4Response_param, string Q5Response_param)
        {
            using (var context = new FSOSSContext())
            {
                SubmittedSurvey newSurvey = new SubmittedSurvey();
                newSurvey.survey_version_id    = survey_version_id_param;
                newSurvey.date_entered         = DateTime.Now;
                newSurvey.unit_id              = unit_id_param;
                newSurvey.meal_id              = meal_id_param;
                newSurvey.participant_type_id  = participant_type_id_param;
                newSurvey.age_range_id         = age_range_id_param;
                newSurvey.gender_id            = gender_id_param;
                newSurvey.contact_request      = contact_request_param;
                newSurvey.contact_room_number  = contact_room_number_param;
                newSurvey.contact_phone_number = contact_phone_number_param;
                context.SubmittedSurveys.Add(newSurvey);
                context.SaveChanges();

                var newSurveyId = (from x in context.SubmittedSurveys
                                   select x.submitted_survey_id).Max();

                ParticipantResponse q1AResponse = new ParticipantResponse();
                q1AResponse.submitted_survey_id = newSurveyId;
                q1AResponse.question_id         = 2;
                q1AResponse.participant_answer  = Q1AResponse_param;
                context.ParticipantResponses.Add(q1AResponse);
                context.SaveChanges();

                ParticipantResponse q1BResponse = new ParticipantResponse();
                q1BResponse.submitted_survey_id = newSurveyId;
                q1BResponse.question_id         = 3;
                q1BResponse.participant_answer  = Q1BResponse_param;
                context.ParticipantResponses.Add(q1BResponse);
                context.SaveChanges();

                ParticipantResponse q1CResponse = new ParticipantResponse();
                q1CResponse.submitted_survey_id = newSurveyId;
                q1CResponse.question_id         = 4;
                q1CResponse.participant_answer  = Q1CResponse_param;
                context.ParticipantResponses.Add(q1CResponse);
                context.SaveChanges();

                ParticipantResponse q1DResponse = new ParticipantResponse();
                q1DResponse.submitted_survey_id = newSurveyId;
                q1DResponse.question_id         = 5;
                q1DResponse.participant_answer  = Q1DResponse_param;
                context.ParticipantResponses.Add(q1DResponse);
                context.SaveChanges();

                ParticipantResponse q1EResponse = new ParticipantResponse();
                q1EResponse.submitted_survey_id = newSurveyId;
                q1EResponse.question_id         = 6;
                q1EResponse.participant_answer  = Q1EResponse_param;
                context.ParticipantResponses.Add(q1EResponse);
                context.SaveChanges();

                ParticipantResponse q2Response = new ParticipantResponse();
                q2Response.submitted_survey_id = newSurveyId;
                q2Response.question_id         = 8;
                q2Response.participant_answer  = Q2Response_param;
                context.ParticipantResponses.Add(q2Response);
                context.SaveChanges();

                ParticipantResponse q3Response = new ParticipantResponse();
                q3Response.submitted_survey_id = newSurveyId;
                q3Response.question_id         = 9;
                q3Response.participant_answer  = Q3Response_param;
                context.ParticipantResponses.Add(q3Response);
                context.SaveChanges();

                ParticipantResponse q4Response = new ParticipantResponse();
                q4Response.submitted_survey_id = newSurveyId;
                q4Response.question_id         = 10;
                q4Response.participant_answer  = Q4Response_param;
                context.ParticipantResponses.Add(q4Response);
                context.SaveChanges();

                ParticipantResponse q5Response = new ParticipantResponse();
                q5Response.submitted_survey_id = newSurveyId;
                q5Response.question_id         = 11;
                q5Response.participant_answer  = Q5Response_param;
                context.ParticipantResponses.Add(q5Response);
                context.SaveChanges();
            }
        }
Esempio n. 20
0
        public async Task <IActionResult> UpdateParticipantDetails(Guid hearingId, Guid participantId, [FromBody] UpdateParticipantRequest request)
        {
            if (hearingId == Guid.Empty)
            {
                ModelState.AddModelError(nameof(hearingId), $"Please provide a valid {nameof(hearingId)}");
                return(BadRequest(ModelState));
            }

            if (participantId == Guid.Empty)
            {
                ModelState.AddModelError(nameof(participantId), $"Please provide a valid {nameof(participantId)}");
                return(BadRequest(ModelState));
            }

            var result = new UpdateParticipantRequestValidation().Validate(request);

            if (!result.IsValid)
            {
                ModelState.AddFluentValidationErrors(result.Errors);
                return(BadRequest(ModelState));
            }

            var getHearingByIdQuery = new GetHearingByIdQuery(hearingId);
            var videoHearing        = await _queryHandler.Handle <GetHearingByIdQuery, VideoHearing>(getHearingByIdQuery);

            if (videoHearing == null)
            {
                return(NotFound());
            }
            Participant participant  = null;
            var         participants = videoHearing.GetParticipants();

            if (participants != null)
            {
                participant = participants.SingleOrDefault(x => x.Id.Equals(participantId));
            }

            if (participant == null)
            {
                return(NotFound());
            }

            if (participant.HearingRole.UserRole.IsIndividual)
            {
                var addressValidationResult = new AddressValidation().Validate(request);
                if (!addressValidationResult.IsValid)
                {
                    ModelState.AddFluentValidationErrors(result.Errors);
                    return(BadRequest(ModelState));
                }
            }

            if (participant.HearingRole.UserRole.IsRepresentative)
            {
                var repValidationResult = new RepresentativeValidation().Validate(request);
                if (!repValidationResult.IsValid)
                {
                    ModelState.AddFluentValidationErrors(result.Errors);
                    return(BadRequest(ModelState));
                }
            }

            var mapper  = new UpdateParticipantRequestToNewAddressMapper();
            var address = mapper.MapRequestToNewAddress(request);

            var representativeMapper = new UpdateParticipantRequestToNewRepresentativeMapper();
            var representative       = representativeMapper.MapRequestToNewRepresentativeInfo(request);

            var updateParticipantCommand = new UpdateParticipantCommand(participantId, request.Title,
                                                                        request.DisplayName, request.TelephoneNumber, address,
                                                                        request.OrganisationName, videoHearing, representative);

            await _commandHandler.Handle(updateParticipantCommand);

            var updatedParticipant = updateParticipantCommand.UpdatedParticipant;

            var participantMapper = new ParticipantToResponseMapper();

            ParticipantResponse response = null;

            if (updatedParticipant != null)
            {
                response = participantMapper.MapParticipantToResponse(updatedParticipant);
            }

            // ONLY publish this event when Hearing is set for ready for video
            if (videoHearing.Status == Domain.Enumerations.BookingStatus.Created)
            {
                await _eventPublisher.PublishAsync(new ParticipantUpdatedIntegrationEvent(hearingId, updatedParticipant));
            }

            return(Ok(response));
        }
        private static string GetTiledDisplayName(ParticipantResponse participant, int position)
        {
            var prefix = participant.HearingRole.ToLower().Trim() == "witness" ? "W" : "T";

            return($"{prefix}{position};{participant.DisplayName};{participant.Id}");
        }
        private List <LinkedParticipantRequest> BuildLinkedParticipantRequestForExistingParticipant(HearingDetailsResponse hearing, ParticipantResponse participant, List <LinkedParticipant> linkedParticipantsInRequest)
        {
            var requests = new List <LinkedParticipantRequest>();

            var newLinks = linkedParticipantsInRequest.Where(x => x.LinkedId == Guid.Empty)
                           .Select(lp => new LinkedParticipantRequest
            {
                ParticipantContactEmail       = lp.ParticipantContactEmail,
                LinkedParticipantContactEmail = lp.LinkedParticipantContactEmail
            });

            requests.AddRange(newLinks);

            var existingLinksToUpdate = linkedParticipantsInRequest.Where(x => x.LinkedId != Guid.Empty && !HasExistingLink(x, participant));

            var existingLinks = existingLinksToUpdate.Select(linkedParticipantInRequest =>
                                                             hearing.Participants.First(x => x.Id == linkedParticipantInRequest.LinkedId))
                                .Select(linkedParticipant => new LinkedParticipantRequest
            {
                ParticipantContactEmail = participant.ContactEmail, LinkedParticipantContactEmail = linkedParticipant.ContactEmail
            });

            requests.AddRange(existingLinks);
            return(requests);
        }
        public static AddNotificationRequest MapToNewUserNotification(Guid hearingId, ParticipantResponse participant,
                                                                      string password)
        {
            var parameters = new Dictionary <string, string>
            {
                { "name", $"{participant.FirstName} {participant.LastName}" },
                { "username", $"{participant.Username}" },
                { "random password", $"{password}" }
            };
            var addNotificationRequest = new AddNotificationRequest
            {
                HearingId        = hearingId,
                MessageType      = MessageType.Email,
                ContactEmail     = participant.ContactEmail,
                NotificationType = participant.UserRoleName.ToUpper() == Individual
                    ? NotificationType.CreateIndividual
                    : NotificationType.CreateRepresentative,
                ParticipantId = participant.Id,
                PhoneNumber   = participant.TelephoneNumber,
                Parameters    = parameters
            };

            return(addNotificationRequest);
        }
Esempio n. 24
0
 public void GivenThereIsAHearingWithQuestionnaireAnswers(string role)
 {
     _participantResponse = _c.Test.HearingResponse.Participants.First(x => x.UserRoleName.ToLower().Equals(role.ToLower()));
     AddSuitabilityAnswers(_c.Test.HearingResponse.Id, _participantResponse.Id, role.ToLower());
 }
        private void TheToolTipDetailsAreDisplayed(ParticipantDetailsResponse participant, ParticipantResponse hearingParticipant)
        {
            var participantEmailAndRole = $"{participant.Name}";

            _browsers[_c.CurrentUser].TextOf(VhoHearingListPage.ParticipantContactName(participant.Id)).Should().Be(participantEmailAndRole);
            _browsers[_c.CurrentUser].TextOf(VhoHearingListPage.ParticipantContactEmail(participant.Id)).Should().Be(hearingParticipant.ContactEmail);
            _browsers[_c.CurrentUser].TextOf(VhoHearingListPage.ParticipantContactPhone(participant.Id)).Should().Be(hearingParticipant.TelephoneNumber);
        }