public GasStationRepository(IClosestNetworkLocationSettings settings) { Settings = settings ?? throw new ArgumentNullException(nameof(settings)); var client = new MongoClient(settings.ConnectionString); var database = client.GetDatabase(settings.DatabaseName); Collection = database.GetCollection <GasStation>(settings.CollectionName); var locationIndexBuilder = Builders <GasStation> .IndexKeys; var indexModel = new CreateIndexModel <GasStation>(locationIndexBuilder.Geo2DSphere(_ => _.Address.Location)); Collection.Indexes.CreateOneAsync(indexModel).ConfigureAwait(false); }
public GeolocationExternalService(IHttpClientFactory clientFactory, IClosestNetworkLocationSettings settings) { ClientFactory = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory)); Settings = settings ?? throw new ArgumentNullException(nameof(settings)); }