public async Task <ContactV1> Handle(GetContactRequestV1 request, CancellationToken cancellationToken)
        {
            var contact = _mapper.Map <ContactV1>(await _contactRepository.GetContactById(request.Id, cancellationToken));

            contact.Skills = new List <SkillV1>();

            var listLinkContactSkill = await _linkRepository.GetAllLinkByContactId(contact.Id, cancellationToken);

            foreach (var linkContactSkill in listLinkContactSkill)
            {
                var skill = await _skillRepository.GetSkillById(linkContactSkill.IdSkill, cancellationToken);

                contact.Skills.Add(_mapper.Map <SkillV1>(skill));
            }
            return(contact);
        }
예제 #2
0
        public async Task <List <ContactV1> > Handle(GetAllContactRequestV1 request, CancellationToken cancellationToken)
        {
            //get the contact and all the skills linked to it
            var listContact = _mapper.Map <List <ContactV1> >(await _contactRepository.GetAll());

            foreach (var contact in listContact)
            {
                contact.Skills = new List <SkillV1>();
                var listLinkContactSkill = await _linkRepository.GetAllLinkByContactId(contact.Id, cancellationToken);

                foreach (var linkContactSkill in listLinkContactSkill)
                {
                    var skill = await _skillRepository.GetSkillById(linkContactSkill.IdSkill, cancellationToken);

                    contact.Skills.Add(_mapper.Map <SkillV1>(skill));
                }
            }
            return(listContact);
        }