public List <DtoStore> GetNearStore(DtoGeolocation request)
        {
            var mylocation = new GeoCoordinate(request.Latitude, request.Longitude);

            var stores = storeRepository.GetAllStores();

            foreach (var store in stores)
            {
                var storeLocation = new GeoCoordinate(store.Address.Latitude.Value, store.Address.Longitude.Value);
                store.Proximity = mylocation.GetDistanceTo(storeLocation);

                // removendo deliverys não alcançados
                store.AvaibleDeliveries = store.AvaibleDeliveries
                                          .Where(i => i.MaxDistance > store.Proximity).ToList();
            }

            // removendo stores sem deliverys
            stores = stores.Where(i => i.AvaibleDeliveries.Count() > 0).ToList();


            return(stores.Where(i => i.Proximity <= i.MaxDistance).ToList());
        }
Esempio n. 2
0
 public List <DtoStore> Fulltext([FromUri] DtoGeolocation request)
 {
     return(StoreDomain.GetNearStore(request));
 }