Exemplo n.º 1
0
        public ActionResult GetAllProducts()
        {
            //will check if there are any old openmats and then delete them
            _gymRepository.DeleteOpenMat();
            var user = _gymRepository.GetAll();

            return(Ok(user));
        }
        private int[] GetFortIdsForFence(FenceConfiguration fence)
        {
            var result  = new List <int>();
            var allGyms = GymRepository.GetAll().ToList();

            foreach (var gym in allGyms)
            {
                var coordinate = new Coordinate(gym.Latitude, gym.Longitude);
                if (fence.Area.Contains(coordinate))
                {
                    result.Add(gym.Id);
                }
            }
            return(result.ToArray());
        }
        private IQueryable <IGym> GetGyms(FenceConfiguration[] fences = null)
        {
            if (fences != null && fences.Any())
            {
                var fortIds = new List <int>();
                foreach (var fence in fences)
                {
                    var ids = GymsByFences.GetOrAdd(fence, GetFortIdsForFence);
                    fortIds.AddRange(ids);
                }
                fortIds = fortIds.Distinct().ToList();

                return(GymRepository.FindAll(e => fortIds.Contains(e.Id)));
            }
            return(GymRepository.GetAll());
        }