Esempio n. 1
0
        public static SkillSetDTO Map(FilterViewModel skills)
        {
            var result = new SkillSetDTO {
                Skills = new List <SkillValueDTO>(), IncludeTeamed = skills.IncludeTeamed
            };

            foreach (var cat in skills.Categories)
            {
                foreach (var s in cat.Skills)
                {
                    result.Skills.Add(Map(s));
                }
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets all users with categorized skills by target filter.
        /// </summary>
        /// <param name="ss"></param>
        /// <returns></returns>
        public List <CategorizedUserDTO> GetUsers(SkillSetDTO ss)
        {
            var result = from u in Database.Users.GetAll()
                         where ss.Skills.All(query => query.Value == 0 || u.Skills.Any(y => y.Skill.Id == query.Skill.Id && y.Value >= query.Value))
                         select u;

            if (!ss.IncludeTeamed)
            {
                result = result.Where(x => x.Teams.Count == 0);
            }

            if (result.Count() == 0)
            {
                throw new ValidationException("Query yilded no results.", "");
            }

            var cats = Database.Categories.GetAll().ToList();

            return(Mapper.Map(result.ToList(), cats));
        }