public async Task BulkImport(BulkImportRequest bulk) { foreach (var request in bulk.Requests) { var name = request.Organization.Name; var city = request.Organization.City; var state = request.Organization.State; var existing = _requestContainer .GetItemLinqQueryable <MaskRequest>(true) .Where(x => x.Organization.Name == name && x.Organization.City == city && x.Organization.State == state) .Select(x => x) .ToList(); if (existing.Any()) { var source = existing.First(); request.Id = source.Id; request.RequestDate = source.RequestDate; request.Organization.Geolocation = source.Organization.Geolocation; await _requestContainer.UpsertItemAsync(request); } else { request.Id = Guid.NewGuid().ToString(); request.RequestDate = DateTime.Now; await _geocodingProvider.Locate(request); await _requestContainer.UpsertItemAsync(request); } } }
public void ImportRequests([FromBody] BulkImportRequest requests) { _dataProvider.BulkImport(requests); }