Example #1
0
        public async Task <IEnumerable <Developer> > GetDevelopersBySkillAsync(int skillLevel = 0)
        {
            if (skillLevel < 0)
            {
                throw new ServiceParameterException("Skill level cannot be negative");
            }

            var allDevelopers = await _apiClient.Execute(new GetAllDevelopersRequest());

            return(from developer in allDevelopers
                   let types = developer.Skills.Where(s => s.Level >= skillLevel).Select(s => s.Type).Distinct().ToList()
                               where types.Count > 0
                               let skills = developer.Skills.Where(s => types.Contains(s.Type)).ToList()
                                            select new Developer()
            {
                Age = developer.Age,
                FirstName = developer.FirstName,
                LastName = developer.LastName,
                Skills = skills
            });
        }