Пример #1
0
 public ProfileResponseDto map(Profile profile)
 {
     return(new ProfileResponseDto()
     {
         ID = profile.ID,
         Name = profile.Name,
         Uid = profile.UID,
         Skills = profile.ProfileSkills != null?profile.ProfileSkills.Select(global => _skillMapper.map(global.Skill)).ToList() : new List <SkillDto>(),
                      Location = _geometryMapper.map(profile.Address, profile.Point)
     });
 }
        public Paginated <Profile> Search(string uid, IEnumerable <int> skills, LocationRadius locationRadius, int page, int pageSize)
        {
            using (var context = _ctxFactory.Get())
            {
                var res = context.Profiles.Include(p => p.ProfileSkills).ThenInclude(ps => ps.Skill).AsQueryable <Profile>();

                if (skills != null)
                {
                    res = res.Where(p => p.ProfileSkills.Where(s => skills.Contains(s.SkillID)).Count().Equals(skills.Count()));
                }

                if (!string.IsNullOrEmpty(uid))
                {
                    res = res.Where(p => p.UID.Equals(uid));
                }

                if (locationRadius != null)
                {
                    res = res.Where(p => p.Point.Distance(_geometryMapper.map(locationRadius)) <= locationRadius.Radius);
                }

                return(new Paginated <Profile>(page, pageSize, res));
            }
        }