/// <summary>
        /// Post action from the /settings view.
        /// </summary>
        /// <param name="appOptions">The options provided by the user.</param>
        /// <returns>The updated view or the current view with validation errors.</returns>
        public IActionResult OnPost(SelectedOptions appOptions)
        {
            if (!ModelState.IsValid)
            {
                TempData["Invalid"] = true;
                return(Page());
            }

            if (appOptions.EnableEditorialFeatures)
            {
                HttpContext.Session.SetString("EditorialFeatures", "Enabled");
            }
            else
            {
                HttpContext.Session.SetString("EditorialFeatures", "Disabled");
            }

            var currentOptions = new ContentfulOptions
            {
                DeliveryApiKey = appOptions.AccessToken,
                SpaceId        = appOptions.SpaceId,
                UsePreviewApi  = _manager.Options.UsePreviewApi,
                PreviewApiKey  = appOptions.PreviewToken,
                MaxNumberOfRateLimitRetries = _manager.Options.MaxNumberOfRateLimitRetries,
                ResolveEntriesSelectively   = _manager.Options.ResolveEntriesSelectively,
                ManagementApiKey            = _manager.Options.ManagementApiKey
            };

            HttpContext.Session.SetString(nameof(ContentfulOptions), JsonConvert.SerializeObject(currentOptions));
            TempData["Success"] = true;

            return(RedirectToPage("Settings"));
        }
 /// <summary>
 /// Instantiates the model.
 /// </summary>
 /// <param name="manager">The class that manages the Contentful configuration for the application.</param>
 /// <param name="client">The client used to communicate with the Contentful API.</param>
 public SettingsModel(IContentfulOptionsManager manager, IContentfulClient client)
 {
     Options    = manager.Options;
     _client    = client;
     _manager   = manager;
     AppOptions = new SelectedOptions
     {
         SpaceId       = Options.SpaceId,
         UsePreviewApi = Options.UsePreviewApi,
         AccessToken   = Options.DeliveryApiKey,
         PreviewToken  = Options.PreviewApiKey
     };
 }