private void CreateGroupIdToChannelNameDic() { groupToAddtionalChannelDic = new Dictionary <string, string>(); Dictionary <string, string> countyToAlertDic = CreateCountyToAlertDic(); IEnumerable <AADIdentity> groups = groupsController.GetGroups(graphClientManager.GetGraphHttpClient()) .GetAwaiter().GetResult(); foreach (string countyName in countyToAlertDic.Keys) { bool groupAlreayCreated = false; foreach (AADIdentity identity in groups) { if (identity.DisplayName.Equals(countyName, StringComparison.InvariantCultureIgnoreCase)) { groupToAddtionalChannelDic.Add(identity.Id, countyToAlertDic[countyName]); groupAlreayCreated = true; break; } } if (!groupAlreayCreated) { AADIdentity group = groupsController .CreateGroup(graphClientManager.GetGraphHttpClient(), countyName).GetAwaiter().GetResult(); groupToAddtionalChannelDic.Add(group.Id, countyToAlertDic[countyName]); } } }
public IEnumerable <string> GetNewTeamsGroupIds() { List <string> groupIdList = new List <string>(); IEnumerable <AADIdentity> groups = groupsController.GetGroups(graphClientManager.GetGraphHttpClient()) .GetAwaiter().GetResult(); foreach (string stateName in GetUSStateNamesHasConfirmedCases()) { AADIdentity group = groups.FirstOrDefault(x => x.DisplayName.Equals(stateName, StringComparison.InvariantCultureIgnoreCase)); if (group == null) { Console.WriteLine($"Warning: Cannot find group with display name '{stateName}'"); } else { groupIdList.Add(group.Id); } } return(groupIdList); }