/// <summary> /// Creates the editable user profile card /// </summary> /// <param name="userId">User id the profile is for</param> /// <param name="userName">User name the profile is for</param> /// <param name="teamName">Team name subteam name hint is for</param> /// <param name="discipline">User discipline</param> /// <param name="gender">User gender</param> /// <param name="seniority">User seniority</param> /// <param name="teams">Sub team names the user has been on</param> /// <param name="subteamNamesHint">List of suggested sub team names. Can be empty</param> /// <param name="lowPreferenceNames">List of full names the user has low preference for. Can be empty</param> /// <param name="isOnBehalfOfAnotherUser">Show different title when this card is show for another user</param> /// <returns>user profile card</returns> public static string GetCardJson( string userId, string userName, string teamName, string discipline, string gender, string seniority, List <string> teams, string subteamNamesHint, List <string> lowPreferenceNames, bool isOnBehalfOfAnotherUser = false) { var teamNamesHint = string.IsNullOrEmpty(subteamNamesHint) ? string.Empty : $"Teams in {teamName}: " + subteamNamesHint; // TODO: Lots of strings to put in the resources including those in the json file var variablesToValues = new Dictionary <string, string>() { { "title", isOnBehalfOfAnotherUser ? $"Edit Profile for {userName}" : $"Tell me about yourself" }, { "description", "This helps me improve your matches." }, { "defaultDiscipline", GetValueOrDefault(discipline, DEFAULTDISCIPLINE) }, { "defaultGender", GetValueOrDefault(gender, DEFAULTGENDER) }, { "defaultSeniority", GetValueOrDefault(seniority, DEFAULTSENIORITY) }, { "defaultTeams", string.Join(TeamsSeparatorWithSpace, teams) }, { "teamNamesHint", teamNamesHint }, { "defaultLowPreferenceNames", string.Join(NamesSeparatorWithSpace, lowPreferenceNames) }, { "userId", userId } }; return(AdaptiveCardHelper.ReplaceTemplateKeys(CardTemplate, variablesToValues)); }
/// <summary> /// Creates the welcome new member card that welcomes the user to a specific team. /// </summary> /// <param name="teamContext">Team context for the card.</param> /// <param name="userStatus">User status</param> /// <param name="botInstallerName">The name of the person that installed the bot to the team. Can be empty.</param> /// <param name="showAdminActions">Whether to show the admin actions</param> /// <returns>The welcome new member card</returns> public static AdaptiveCard GetCard(TeamContext teamContext, EnrollmentStatus userStatus, string botInstallerName, bool showAdminActions) { string introMessagePart1; if (string.IsNullOrEmpty(botInstallerName)) { introMessagePart1 = string.Format(Resources.InstallMessageUnknownInstaller, teamContext.TeamName); } else { introMessagePart1 = string.Format(Resources.InstallMessageKnownInstaller, botInstallerName, teamContext.TeamName); } var introMessagePart2 = Resources.InstallMessageBotDescription; var introMessagePart3 = showAdminActions ? Resources.InstallMessageInstructionAdmin : Resources.InstallMessageInstruction; var suggestedNextStep = showAdminActions ? string.Format(Resources.InstallMessageSuggestedNextStepAdmin, Resources.MakePairsButtonText) : Resources.InstallMessageSuggestedNextStep; var baseDomain = CloudConfigurationManager.GetSetting("AppBaseDomain"); var welcomeCardImageUrl = $"https://{baseDomain}/Content/welcome-card-image.png"; var salutationText = Resources.SalutationTitleText; var variablesToValues = new Dictionary <string, string>() { { "salutationText", salutationText }, { "welcomeCardImageUrl", welcomeCardImageUrl }, { "introMessagePart1", introMessagePart1 }, { "introMessagePart2", introMessagePart2 }, { "introMessagePart3", introMessagePart3 }, { "suggestedNextStep", suggestedNextStep }, }; var cardBody = AdaptiveCardHelper.ReplaceTemplateKeys(CardTemplate, variablesToValues); var card = AdaptiveCard.FromJson(cardBody).Card; if (showAdminActions) { var adminActions = AdaptiveCardHelper.CreateAdminActions(teamContext); card.Actions.AddRange(adminActions); } var userActions = AdaptiveCardHelper.CreateUserActions(teamContext, userStatus); card.Actions.AddRange(userActions); return(card); }
/// <summary> /// Creates the edit team settings card /// </summary> /// <param name="teamId">Team id</param> /// <param name="teamName">User discipline</param> /// <param name="adminUser">Admin user. Can be null if bot installed by Graph or changed to no admin</param> /// <param name="teamNotifyMode">How pairings will be notified</param> /// <param name="subteamNames">Sub team names hints for Edit Profile page</param> /// <returns>user profile card</returns> public static AdaptiveCard GetCard(string teamId, string teamName, User adminUser, string teamNotifyMode, string subteamNames) { var variablesToValues = new Dictionary <string, string>() { { "teamId", teamId }, { "teamName", teamName }, { "noApprovalValue", TeamInstallInfo.NotifyModeNoApproval }, { "needApprovalValue", TeamInstallInfo.NotifyModeNeedApproval }, { "defaultNotifyMode", teamNotifyMode }, { "subteamNames", subteamNames }, { "adminUserName", adminUser == null ? string.Empty : adminUser.Name }, { "originalAdminUserId", adminUser == null ? string.Empty : adminUser.AadId }, { "originalAdminUserName", adminUser == null ? string.Empty : adminUser.Name } }; var cardJson = AdaptiveCardHelper.ReplaceTemplateKeys(CardTemplate, variablesToValues); // There is an AdaptiveCard template library but it's only for .NET core. var card = AdaptiveCard.FromJson(cardJson).Card; return(card); }