public async Task Should_Update_Participant_With_Links() { var editPrefix = " _Edit"; var seededHearing = await Hooks.SeedVideoHearing(); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var individuals = seededHearing.GetParticipants() .Where(x => x.HearingRole.UserRole.Name.Equals("Individual")).ToList(); var interpretee = individuals[0]; var interpreter = individuals[1]; var link = new LinkedParticipantDto( interpreter.Person.ContactEmail, interpretee.Person.ContactEmail, LinkedParticipantType.Interpreter); var title = interpreter.Person.Title + editPrefix; var displayName = interpreter.DisplayName + editPrefix; var telephoneNumber = "11112222333"; var links = new List <LinkedParticipantDto> { link }; var updateParticipantCommand = new UpdateParticipantCommand(seededHearing.Id, interpreter.Id, title, displayName, telephoneNumber, null, null, links); await _commandHandler.Handle(updateParticipantCommand); var updatedRepresentative = updateParticipantCommand.UpdatedParticipant; updatedRepresentative.Should().NotBeNull(); updatedRepresentative.LinkedParticipants.Should().NotBeNull(); updatedRepresentative.GetLinkedParticipants().Should().NotBeEmpty(); }
public async Task Should_be_able_to_update_representative_participant() { var editPrefix = " _Edit"; var seededHearing = await Hooks.SeedVideoHearing(); var beforeUpdatedDate = seededHearing.UpdatedDate; TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); _newHearingId = seededHearing.Id; var representativeParticipant = seededHearing.GetParticipants().First(x => x.HearingRole.UserRole.Name.Equals("Representative")); var title = representativeParticipant.Person.Title + editPrefix; var displayName = representativeParticipant.DisplayName + editPrefix; var telephoneNumber = "11112222333"; var organisationName = "Organisation" + editPrefix; var representee = "Iron Man Inc."; RepresentativeInformation repInfo = new RepresentativeInformation() { Representee = representee }; var updateParticipantCommand = new UpdateParticipantCommand(_newHearingId, representativeParticipant.Id, title, displayName, telephoneNumber, organisationName, repInfo, null); await _commandHandler.Handle(updateParticipantCommand); var updatedRepresentative = (Representative)updateParticipantCommand.UpdatedParticipant; updatedRepresentative.Should().NotBeNull(); updatedRepresentative.UpdatedDate.Should().BeAfter(beforeUpdatedDate); updatedRepresentative.Person.Title.Should().Be(title); updatedRepresentative.DisplayName.Should().Be(displayName); updatedRepresentative.Person.TelephoneNumber.Should().Be(telephoneNumber); updatedRepresentative.Person.Organisation.Should().NotBeNull(); updatedRepresentative.Person.Organisation.Name.Should().Be(organisationName); updatedRepresentative.Representee.Should().Be(repInfo.Representee); }
public async Task Should_be_able_to_update_individual_participant() { var editPrefix = " _Edit"; var seededHearing = await Hooks.SeedVideoHearing(); var beforeUpdatedDate = seededHearing.UpdatedDate; TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); _newHearingId = seededHearing.Id; var individualParticipant = seededHearing.GetParticipants().First(x => x.HearingRole.UserRole.Name.Equals("Individual")); var title = individualParticipant.Person.Title + editPrefix; var displayName = individualParticipant.DisplayName + editPrefix; var telephoneNumber = "11112222333"; var organisationName = "Organisation" + editPrefix; var updateParticipantCommand = new UpdateParticipantCommand(_newHearingId, individualParticipant.Id, title, displayName, telephoneNumber, organisationName, null, null); await _commandHandler.Handle(updateParticipantCommand); var updatedIndividual = (Individual)updateParticipantCommand.UpdatedParticipant; updatedIndividual.Should().NotBeNull(); updatedIndividual.UpdatedDate.Should().BeAfter(beforeUpdatedDate); updatedIndividual.Person.Title.Should().Be(title); updatedIndividual.DisplayName.Should().Be(displayName); updatedIndividual.Person.TelephoneNumber.Should().Be(telephoneNumber); }
public async Task <ActionResult> Update(int id, UpdateParticipantCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public async Task Should_be_able_to_update_representative_participant() { var editPrefix = " _Edit"; var seededHearing = await Hooks.SeedVideoHearing(); var beforeUpdatedDate = seededHearing.UpdatedDate; TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); _newHearingId = seededHearing.Id; var representativeParticipant = seededHearing.GetParticipants().FirstOrDefault(x => x.HearingRole.UserRole.Name.Equals("Representative")); var title = representativeParticipant.Person.Title + editPrefix; var displayName = representativeParticipant.DisplayName + editPrefix; var telephoneNumber = "11112222333"; var houseNumber = "HouseNumber" + editPrefix; var street = "Street" + editPrefix; var postcode = "ED1 5NR"; var city = "City" + editPrefix; var county = "County" + editPrefix; var organisationName = "Organisation" + editPrefix; NewAddress address = new NewAddress() { HouseNumber = houseNumber, Street = street, City = city, County = county, Postcode = postcode }; const string reference = "Marvel Comics Division"; var representee = "Iron Man Inc."; RepresentativeInformation repInfo = new RepresentativeInformation() { Reference = reference, Representee = representee }; var updateParticipantCommand = new UpdateParticipantCommand(representativeParticipant.Id, title, displayName, telephoneNumber, address, organisationName, seededHearing, repInfo); await _commandHandler.Handle(updateParticipantCommand); var updatedRepresentative = (Representative)updateParticipantCommand.UpdatedParticipant; updatedRepresentative.Should().NotBeNull(); updatedRepresentative.UpdatedDate.Should().BeAfter(beforeUpdatedDate); updatedRepresentative.Person.Title.Should().Be(title); updatedRepresentative.DisplayName.Should().Be(displayName); updatedRepresentative.Person.TelephoneNumber.Should().Be(telephoneNumber); updatedRepresentative.Person.Address.Should().BeNull(); updatedRepresentative.Person.Organisation.Should().NotBeNull(); updatedRepresentative.Person.Organisation.Name.Should().Be(organisationName); updatedRepresentative.Reference.Should().Be(repInfo.Reference); updatedRepresentative.Representee.Should().Be(repInfo.Representee); }
public async Task Should_be_able_to_update_individual_participant() { var editPrefix = " _Edit"; var seededHearing = await Hooks.SeedVideoHearing(); var beforeUpdatedDate = seededHearing.UpdatedDate; TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); _newHearingId = seededHearing.Id; var individualParticipant = seededHearing.GetParticipants().SingleOrDefault(x => x.HearingRole.UserRole.Name.Equals("Individual")); var title = individualParticipant.Person.Title + editPrefix; var displayName = individualParticipant.DisplayName + editPrefix; var telephoneNumber = "11112222333"; var houseNumber = individualParticipant.Person.Address?.HouseNumber + editPrefix; var street = individualParticipant.Person.Address?.Street + editPrefix; var postcode = individualParticipant.Person.Address?.Postcode + editPrefix; var city = "City" + editPrefix; var county = "County" + editPrefix; var organisationName = "Organisation" + editPrefix; NewAddress address = new NewAddress() { HouseNumber = houseNumber, Street = street, City = city, County = county, Postcode = postcode }; var updateParticipantCommand = new UpdateParticipantCommand(individualParticipant.Id, title, displayName, telephoneNumber, address, organisationName, seededHearing, null); await _commandHandler.Handle(updateParticipantCommand); var updatedIndividual = (Individual)updateParticipantCommand.UpdatedParticipant; updatedIndividual.Should().NotBeNull(); updatedIndividual.UpdatedDate.Should().BeAfter(beforeUpdatedDate); updatedIndividual.Person.Title.Should().Be(title); updatedIndividual.DisplayName.Should().Be(displayName); updatedIndividual.Person.TelephoneNumber.Should().Be(telephoneNumber); updatedIndividual.Person.Address.HouseNumber.Should().Be(houseNumber); updatedIndividual.Person.Address.Street.Should().Be(street); updatedIndividual.Person.Address.Postcode.Should().Be(postcode); }
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 <ActionResult> Update([FromBody] UpdateParticipantCommand updateParticipantCommand) { await _mediator.Send(updateParticipantCommand); return(NoContent()); }