static string EvaluateConsentResult(UserAgeConsentResult consentResult) { switch (consentResult) { case UserAgeConsentResult.Included: case UserAgeConsentResult.NotEnforced: return("Allowed."); case UserAgeConsentResult.NotIncluded: return("Not allowed."); case UserAgeConsentResult.Unknown: return("Cannot determine. Default to app specific age unknown behavior."); default: case UserAgeConsentResult.Ambiguous: return("Age regulations have changed, the app needs to be updated to reflect new catagories."); } }
private async void ShowConsentGroups(object sender, RoutedEventArgs e) { var selectedUser = (UserViewModel)UserList.SelectedValue; if (selectedUser != null) { ResultsText.Text = ""; rootPage.NotifyUser("", NotifyType.StatusMessage); try { User user = User.GetFromId(selectedUser.UserId); String result = ""; UserAgeConsentResult canShowChildContent = await user.CheckUserAgeConsentGroupAsync(UserAgeConsentGroup.Child); result += "Child content: " + EvaluateConsentResult(canShowChildContent) + "\n"; UserAgeConsentResult canShowMinorContent = await user.CheckUserAgeConsentGroupAsync(UserAgeConsentGroup.Minor); result += "Minor content: " + EvaluateConsentResult(canShowMinorContent) + "\n"; UserAgeConsentResult canShowAdultContent = await user.CheckUserAgeConsentGroupAsync(UserAgeConsentGroup.Adult); result += "Adult content: " + EvaluateConsentResult(canShowAdultContent) + "\n"; ResultsText.Text = result; } catch (Exception ex) { // Operations on the "User" object fail if the user signs out. rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage); } } }