Ejemplo n.º 1
0
        public async Task <IActionResult> Create(string SelectedTheme,
                                                 string SelectedColor,
                                                 string SelectedLanguage)
        {
            await EnsureScopes(_userScopes);

            try
            {
                var roamingSettings = RoamingSettings.Create(SelectedTheme, SelectedColor, SelectedLanguage);

                var extension = roamingSettings.ToOpenExtension();

                //POST /me/extensions

                /*
                 * {
                 * "@odata.type": "microsoft.graph.openTypeExtension",
                 * "extensionName": "com.contoso.roamingSettings",
                 * "theme": "...",
                 * "color": "...",
                 * "language": "..."
                 * }
                 */
                await _graphClient.Me
                .Extensions
                .Request()
                .AddAsync(extension);

                return(RedirectToAction("Index")
                       .WithSuccess("Roaming settings created"));
            }
            catch (ServiceException ex)
            {
                InvokeAuthIfNeeded(ex);

                return(RedirectToAction("Index")
                       .WithError("Error creating extension",
                                  ex.Error.Message));
            }
        }