예제 #1
0
        public void Should_Throw_Exception_When_Link_Does_Not_Exists()
        {
            var linkedParticipant = new LinkedParticipant(_linkedIndividual.Id, Guid.NewGuid(), LinkedParticipantType.Interpreter);

            _individual.Invoking(x => x.RemoveLink(linkedParticipant)).Should()
            .Throw <DomainRuleException>();
        }
예제 #2
0
        public Task CreateParticipantLinks(List <Participant> participants, List <LinkedParticipantDto> linkedParticipantDtos)
        {
            var linkedParticipants = new List <LinkedParticipant>();

            foreach (var linkedParticipantDto in linkedParticipantDtos)
            {
                var interpretee =
                    participants.Single(x =>
                                        x.Person.ContactEmail.Equals(linkedParticipantDto.ParticipantContactEmail,
                                                                     StringComparison.CurrentCultureIgnoreCase));
                var interpreter =
                    participants.Single(x =>
                                        x.Person.ContactEmail.Equals(linkedParticipantDto.LinkedParticipantContactEmail,
                                                                     StringComparison.CurrentCultureIgnoreCase));

                var linkedParticipant = new LinkedParticipant(interpretee.Id, interpreter.Id,
                                                              linkedParticipantDto.Type);

                linkedParticipants.Add(linkedParticipant);

                UpdateParticipantsWithLinks(interpretee, interpreter, linkedParticipantDto.Type);
            }

            return(Task.FromResult(linkedParticipants));
        }
 public static LinkedParticipantResponse MapLinkedParticipantsToResponse(LinkedParticipant linkedParticipant)
 {
     return(new LinkedParticipantResponse()
     {
         Type = linkedParticipant.Type.MapToContractEnum(),
         LinkedId = linkedParticipant.LinkedId
     });
 }
예제 #4
0
 public static LinkedParticipantDto MapToDto(LinkedParticipant linkedParticipant)
 {
     return(new LinkedParticipantDto
     {
         ParticipantId = linkedParticipant.ParticipantId,
         LinkedId = linkedParticipant.LinkedId,
         Type = linkedParticipant.Type
     });
 }
예제 #5
0
        public void should_map_all_properties()
        {
            var linkedParticipant =
                new LinkedParticipant(Guid.NewGuid(), Guid.NewGuid(), LinkedParticipantType.Interpreter);

            var response = LinkedParticipantToResponseMapper.MapLinkedParticipantsToResponse(linkedParticipant);

            response.LinkedId.Should().Be(linkedParticipant.LinkedId);
            response.Type.Should().Be(linkedParticipant.Type);
        }
예제 #6
0
        public void RemoveLink(LinkedParticipant linkedParticipant)
        {
            var link = LinkedParticipants.SingleOrDefault(
                x => x.LinkedId == linkedParticipant.LinkedId && x.Type == linkedParticipant.Type);

            if (link == null)
            {
                throw new DomainRuleException("LinkedParticipant", "Link does not exist");
            }

            LinkedParticipants.Remove(linkedParticipant);
        }
        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);
        }
예제 #8
0
 public void SetUp()
 {
     _linkedParticipant = BuildLinkedParticipant();
 }