Exemplo n.º 1
0
        public void EditEmployeeProfile(string employeeId, int age, string aboutMe, int[] skillsId)
        {
            var employeeProfile = _employeeRepository.FindEmployeeById(employeeId);

            if (employeeProfile == null)
            {
                throw new ObjectNotFoundException($"Employee profile with id={employeeId} not found");
            }

            employeeProfile.Age     = age;
            employeeProfile.AboutMe = aboutMe;
            employeeProfile.Skills.Clear();

            foreach (var skillId in skillsId)
            {
                Skill skill = _skillRepository.FindById(skillId);

                if (skill == null)
                {
                    throw new ObjectNotFoundException($"Skill with id={skillId} not found");
                }

                employeeProfile.Skills.Add(skill);
            }

            _employeeRepository.Update(employeeProfile);
        }