public List <ListItemBO> GetEstablishmentInRadius(int eventId, int radius = 1) { var dbEvent = _eventRepository.GetEventDetail(eventId); if (dbEvent == null) { return(null); } var dbEstablishments = new List <ItemEntity>(_establishmentRepository.GetAllEstablishments()); for (int i = dbEstablishments.Count - 1; i >= 0; i--) { var distance = _locationService.GetDistance(Double.Parse(dbEvent.Longitude), Double.Parse(dbEvent.Latitude), Double.Parse(dbEstablishments[i].Longitude), Double.Parse(dbEstablishments[i].Latitude)); if (distance > MaxDistance) { dbEstablishments.RemoveAt(i); } } var establishments = _mapper.Map <List <ListItemBO> >(dbEstablishments); return(establishments); }