Пример #1
0
        public List <Skill> GetSkillsByDescription(string html)
        {
            var skillIds = new List <int>();
            var doc      = new HtmlDocument();

            doc.LoadHtml(html);
            var nodes = doc.DocumentNode.SelectNodes("//li")?.Select(x => x.InnerHtml).ToList();

            if (nodes != null)
            {
                var skillsConcated      = string.Join(" ", nodes).ToLower();
                var allSkillsDictionary = GetSkillsDictionary();
                foreach (var skill in allSkillsDictionary)
                {
                    foreach (var skillName in skill.Value)
                    {
                        if (skillsConcated.Contains(skillName.ToLower()))
                        {
                            skillIds.Add(int.Parse(skill.Key));
                            break;
                        }
                    }
                }

                var skills = _repository.GetSkillsByIds(skillIds.Distinct().ToList());
                return(skills.ToList());
            }

            return(new List <Skill>());
        }