private async Task Updatehighways(OsmChange changes) { var deleteTasks = new List <Task>(); foreach (var highwaysToRemove in changes.Delete.OfType <Way>()) { var task = _elasticSearchGateway.DeleteHighwaysById(highwaysToRemove.Id.ToString()); deleteTasks.Add(task); } await Task.WhenAll(deleteTasks); var updateTasks = new List <Task <CompleteWay> >(); foreach (var highwaysToUpdate in changes.Modify .Concat(changes.Create) .OfType <Way>() .Where(w => w.Tags != null && w.Tags.ContainsKey("highway"))) { var task = _osmGateway.GetCompleteWay(highwaysToUpdate.Id.ToString()); updateTasks.Add(task); } var updatedWays = await Task.WhenAll(updateTasks); var geoJsonHighways = _osmGeoJsonPreprocessorExecutor.Preprocess(updatedWays.ToList()); await _elasticSearchGateway.UpdateHighwaysData(geoJsonHighways); }