public static RepresentativeInformation MapRequestToNewRepresentativeInfo(UpdateParticipantRequest requestParticipant) { return(new RepresentativeInformation { Representee = requestParticipant.Representee }); }
public async Task Should_update_participant_in_hearing_and_conference() { await CreateAndConfirmHearing(); var participant = Hearing.Participants.First(x => x.HearingRoleName == RoleData.INDV_HEARING_ROLE_NAME && !x.LinkedParticipants.Any()); var interpreter = Hearing.Participants.FirstOrDefault(x => x.HearingRoleName == RoleData.INTERPRETER_HEARING_ROLE_NAME); var request = new UpdateParticipantRequest { DisplayName = $"{participant.DisplayName} {HearingData.UPDATED_TEXT}", OrganisationName = $"{participant.Organisation} {HearingData.UPDATED_TEXT}", TelephoneNumber = UserData.UPDATED_TELEPHONE_NUMBER, Title = $"{participant.Title} {HearingData.UPDATED_TEXT}", LinkedParticipants = new LinkedParticipantsRequestBuilder(participant.ContactEmail, interpreter.ContactEmail).Build() }; await BookingApiClient.UpdateParticipantDetailsAsync(Hearing.Id, participant.Id, request); var conferenceDetails = await PollForConferenceParticipantUpdated(Hearing.Id, participant.Id, HearingData.UPDATED_TEXT); var updatedParticipant = conferenceDetails.Participants.First(x => x.Username.Equals(participant.Username)); var updatedInterpreter = conferenceDetails.Participants.FirstOrDefault(x => x.HearingRole == RoleData.INTERPRETER_HEARING_ROLE_NAME); updatedParticipant.DisplayName.Should().Be(request.DisplayName); updatedParticipant.ContactTelephone.Should().Be(request.TelephoneNumber); updatedParticipant.LinkedParticipants.FirstOrDefault().LinkedId.Should().Be(updatedInterpreter.Id); }
public Task UpdateParticipantDetails(Guid conferenceId, Guid participantId, UpdateParticipantRequest request) { _logger.LogInformation("Updating participant {ParticipantId} in conference {ConferenceId}", participantId, conferenceId); return(_apiClient.UpdateParticipantDetailsAsync(conferenceId, participantId, request)); }
public void GivenIHaveAnUpdateParticipantToConferenceRequest(Scenario scenario) { Guid conferenceId; UpdateParticipantRequest request; var participantId = Guid.Empty; switch (scenario) { case Scenario.Valid: { conferenceId = _context.Test.Conference.Id; participantId = _context.Test.Conference.Participants.First().Id; request = new UpdateParticipantRequest { Fullname = "Automation_Mr Test_Fullname", FirstName = "Automation_Mr Test_Firstname", LastName = "Automation_Mr Test_Lastname", DisplayName = "Automation_Test_Displayname", Representee = "Automation_Test_Representee" }; break; } case Scenario.Nonexistent: conferenceId = Guid.NewGuid(); participantId = Guid.NewGuid(); request = new UpdateParticipantRequest { Fullname = "Automation_Mr Test_Fullname", FirstName = "Automation_Mr Test_Firstname", LastName = "Automation_Mr Test_Lastname", DisplayName = "Automation_Test_Displayname", Representee = "Automation_Test_Representee" }; break; case Scenario.Invalid: conferenceId = Guid.Empty; request = new UpdateParticipantRequest { Fullname = "Automation_Mr Test_Fullname", FirstName = "Automation_Mr Test_Firstname", LastName = "Automation_Mr Test_Lastname", DisplayName = "Automation_Test_Displayname", Representee = "Automation_Test_Representee" }; break; default: throw new ArgumentOutOfRangeException(nameof(scenario), scenario, null); } _context.Uri = UpdateParticipantFromConference(conferenceId, participantId); _context.HttpMethod = HttpMethod.Patch; var jsonBody = RequestHelper.Serialise(request); _context.HttpContent = new StringContent(jsonBody, Encoding.UTF8, "application/json"); }
public UpdateParticipantRequestBuilder() { _updateParticipantRequest = Builder <UpdateParticipantRequest> .CreateNew() .With(x => x.Title = Name.Prefix()) .With(x => x.TelephoneNumber = Phone.Number()) .With(x => x.DisplayName = Name.FullName()) .With(x => x.OrganisationName = Company.Name()) .With(x => x.Representee = Name.FullName()) .Build(); }
public NewAddress MapRequestToNewAddress(UpdateParticipantRequest requestParticipant) { return(new NewAddress { HouseNumber = requestParticipant.HouseNumber, Street = requestParticipant.Street, City = requestParticipant.City, County = requestParticipant.County, Postcode = requestParticipant.Postcode, }); }
public void TestInitialize() { request = new UpdateParticipantRequest { Title = "Mr", DisplayName = "Update Display Name", TelephoneNumber = "11112222333", OrganisationName = "OrgName", Representee = "Rep", }; }
public async Task <ParticipantResponse> UpdateParticipantTarget(Guid userId, UpdateParticipantRequest request) { var participant = await _participantRepo.Get(userId, request.CompetitionId); participant.EnsureExists("User not in competition."); participant.Target = request.Value; _participantRepo.Update(participant); await _participantRepo.Save(); return(new ParticipantResponse(participant)); }
public static UpdateParticipantRequest MapTo(EditParticipantRequest participant) { var updateParticipantRequest = new UpdateParticipantRequest { Title = participant.Title, DisplayName = participant.DisplayName, OrganisationName = participant.OrganisationName, TelephoneNumber = participant.TelephoneNumber, Representee = participant.Representee, }; return(updateParticipantRequest); }
public void TestInitialize() { _updateParticipantRequest = new UpdateParticipantRequest { Fullname = "Test Name", DisplayName = "Test N", Representee = "Represent" }; MockQueryHandler .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync(TestConference); }
public void GivenIHaveAnUpdateParticipantRequest() { var participant = _context.Test.ConferenceResponse.Participants.First(x => x.UserRole == UserRole.Individual); var request = new UpdateParticipantRequest() { Fullname = $"Updated {participant.Name}", FirstName = $"Updated {participant.FirstName}", LastName = $"Updated {participant.LastName}", DisplayName = $"Updated {participant.DisplayName}", Representee = $"Updated {participant.Representee}" }; _scenarioContext.Add(ParticipantUsernameKey, participant.Username); _context.Request = _context.Patch(UpdateParticipantFromConference(_context.Test.ConferenceResponse.Id, participant.Id), request); }
/// <summary>Snippet for UpdateParticipant</summary> public void UpdateParticipantRequestObject() { // Snippet: UpdateParticipant(UpdateParticipantRequest, CallSettings) // Create client ParticipantsClient participantsClient = ParticipantsClient.Create(); // Initialize request argument(s) UpdateParticipantRequest request = new UpdateParticipantRequest { Participant = new Participant(), UpdateMask = new FieldMask(), }; // Make the request Participant response = participantsClient.UpdateParticipant(request); // End snippet }
public UpdateParticipantRequestBuilder() { _updateParticipantRequest = Builder <UpdateParticipantRequest> .CreateNew() .With(x => x.Title = Name.Prefix()) .With(x => x.TelephoneNumber = Phone.Number()) .With(x => x.DisplayName = Name.FullName()) .With(x => x.HouseNumber = Address.StreetAddress()) .With(x => x.Street = Address.StreetName()) .With(x => x.City = Address.City()) .With(x => x.County = Address.Country()) .With(x => x.Postcode = Address.UkPostCode()) .With(x => x.OrganisationName = Company.Name()) .With(x => x.Representee = Name.FullName()) .With(x => x.Reference = Company.Name()) .Build(); }
public async Task Should_return_error() { var request = new UpdateParticipantRequest(); var result = await _validator.ValidateAsync(request); result.IsValid.Should().BeFalse(); result.Errors.Count.Should().Be(4); result.Errors.Any(x => x.ErrorMessage == UpdateParticipantRequestValidation.NoNameErrorMessage) .Should().BeTrue(); result.Errors.Any(x => x.ErrorMessage == UpdateParticipantRequestValidation.NoDisplayNameErrorMessage) .Should().BeTrue(); result.Errors.Any(x => x.ErrorMessage == UpdateParticipantRequestValidation.NoLastNameErrorMessage) .Should().BeTrue(); result.Errors.Any(x => x.ErrorMessage == UpdateParticipantRequestValidation.NoFirstNameErrorMessage) .Should().BeTrue(); }
public void TestInitialize() { request = new UpdateParticipantRequest { Title = "Mr", DisplayName = "Update Display Name", TelephoneNumber = "11112222333", HouseNumber = "Update 1", Street = "Update Street", City = "Update City", County = "Update County", Postcode = "ED1 5NR", OrganisationName = "OrgName", Representee = "Rep", Reference = "SolRef" }; }
/// <summary>Snippet for UpdateParticipantAsync</summary> public async Task UpdateParticipantRequestObjectAsync() { // Snippet: UpdateParticipantAsync(UpdateParticipantRequest, CallSettings) // Additional: UpdateParticipantAsync(UpdateParticipantRequest, CancellationToken) // Create client ParticipantsClient participantsClient = await ParticipantsClient.CreateAsync(); // Initialize request argument(s) UpdateParticipantRequest request = new UpdateParticipantRequest { Participant = new Participant(), UpdateMask = new FieldMask(), }; // Make the request Participant response = await participantsClient.UpdateParticipantAsync(request); // End snippet }
public async Task <ParticipantResponse> UpdateParticipantInitialValue(Guid userId, UpdateParticipantRequest request) { var participant = await _participantRepo.Get(userId, request.CompetitionId); participant.EnsureExists("Participant not found."); participant.InitialValue = request.Value; _participantRepo.Update(participant); await _participantRepo.Save(); return(new ParticipantResponse(participant)); }
public void Setup() { UpdateParticipantRequest = new UpdateParticipantRequestBuilder().Build(); }
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)); }
public async Task <IActionResult> UpdateParticipantDetailsAsync(Guid conferenceId, Guid participantId, UpdateParticipantRequest request) { _logger.LogDebug("UpdateParticipantDetails"); try { var updateParticipantDetailsCommand = new UpdateParticipantDetailsCommand(conferenceId, participantId, request.Fullname, request.FirstName, request.LastName, request.DisplayName, request.Representee, request.ContactEmail, request.ContactTelephone); await _commandHandler.Handle(updateParticipantDetailsCommand); return(NoContent()); } catch (ConferenceNotFoundException ex) { _logger.LogError(ex, "Unable to find conference"); return(NotFound()); } catch (ParticipantNotFoundException ex) { _logger.LogError(ex, "Unable to find participant"); return(NotFound()); } }
public Task UpdateParticipantDetails(Guid conferenceId, Guid participantId, UpdateParticipantRequest request) { UpdateParticipantDetailsCount++; return(Task.FromResult(HttpStatusCode.OK)); }
public async Task <IActionResult> UpdateParticipantDetailsAsync(Guid conferenceId, Guid participantId, UpdateParticipantRequest request) { _logger.LogDebug("UpdateParticipantDetails"); try { var linkedParticipants = request.LinkedParticipants.Select(x => new LinkedParticipantDto() { ParticipantRefId = x.ParticipantRefId, LinkedRefId = x.LinkedRefId, Type = x.Type.MapToDomainEnum() }).ToList(); var updateParticipantDetailsCommand = new UpdateParticipantDetailsCommand(conferenceId, participantId, request.Fullname, request.FirstName, request.LastName, request.DisplayName, request.Representee, request.ContactEmail, request.ContactTelephone, linkedParticipants); if (!request.Username.IsNullOrEmpty()) { updateParticipantDetailsCommand.Username = request.Username; } await _commandHandler.Handle(updateParticipantDetailsCommand); return(NoContent()); } catch (ConferenceNotFoundException ex) { _logger.LogError(ex, "Unable to find conference"); return(NotFound()); } catch (ParticipantNotFoundException ex) { _logger.LogError(ex, "Unable to find participant"); return(NotFound()); } }