Exemple #1
0
        public async Task <IActionResult> TinifySettings()
        {
            var model = new TinifySettingsViewModel
            {
                Enable        = bool.Parse(await _settingsHelper.Get(Settings.EnableTinifyCompress)),
                StatusMessage = StatusMessage
            };

            if (!model.Enable)
            {
                return(View(model));
            }

            var tinifyKey = await(_settingsHelper.Get(Settings.TinifyApiKey));
            var tinify    = new Tinify(tinifyKey);

            try
            {
                await tinify.ValidateKey();

                model.ApiKeyValid = true;
            }
            catch
            {
                model.ApiKeyValid = false;
            }

            model.CompressedCount = await tinify.GetCompressionCount();

            model.ApiKey = await _settingsHelper.Get(Settings.TinifyApiKey);

            return(View(model));
        }