コード例 #1
0
        public void GetAllBandsTest()
        {
            var bands = bandsAccess.Get("");

            #region Assert
            Assert.AreEqual(3, bands.Count);

            Assert.AreEqual("LaLaLa", bands[0].Name);
            Assert.AreEqual("Poleyn", bands[2].Name);
            #endregion


            bands = bandsAccess.Get("Nothing");
            Assert.AreEqual(0, bands.Count);
        }
コード例 #2
0
        public List <Band> Get(string search, double distance = -1, double markerLat = 0, double markerLng = 0)
        {
            var bandsDB = bandsAccess.Get(search);
            var bands   = new List <Band>();

            bandsDB.ForEach(bandDB => bands.Add(DBToLogic(bandDB)));

            if (distance == -1)
            {
                return(bands);
            }

            var marker        = new LatLng(markerLat, markerLng);
            var filteredBands = new List <Band>();

            foreach (var band in bands)
            {
                if (band.Location == null)
                {
                    continue;
                }
                var bandDistance = Helpers.HaversineDistance(marker, band.Location);
                if (bandDistance <= distance)
                {
                    filteredBands.Add(band);
                }
            }
            return(filteredBands);
        }