Beispiel #1
0
        public ActionResult Index(DataFlow.Web.Models.ApiConfigurationValues vm)
        {
            if (!string.IsNullOrWhiteSpace(vm.INSTANCE_ORGANIZATION_LOGO) && !vm.INSTANCE_ORGANIZATION_LOGO.HasImageExtension())
            {
                ModelState.AddModelError("INSTANCE_ORGANIZATION_LOGO", "Organization logo must end with the following file extensions: jpg, gif, png, or svg.");
            }

            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var apiServerUrl               = ConfigurationService.GetConfigurationByKey(Constants.API_SERVER_URL);
            var apiServerKey               = ConfigurationService.GetConfigurationByKey(Constants.API_SERVER_KEY);
            var apiServerSecret            = ConfigurationService.GetConfigurationByKey(Constants.API_SERVER_SECRET);
            var instanceOrganizationLogo   = ConfigurationService.GetConfigurationByKey(Constants.INSTANCE_ORGANIZATION_LOGO);
            var instanceOrganizationUrl    = ConfigurationService.GetConfigurationByKey(Constants.INSTANCE_ORGANIZATION_URL);
            var instanceEduUseText         = ConfigurationService.GetConfigurationByKey(Constants.INSTANCE_EDU_USE_TEXT);
            var instanceAllowRegistrations = ConfigurationService.GetConfigurationByKey(Constants.INSTANCE_ALLOW_USER_REGISTRATION);

            apiServerUrl.Value               = vm.API_SERVER_URL;
            apiServerKey.Value               = vm.API_SERVER_KEY;
            apiServerSecret.Value            = vm.API_SERVER_SECRET;
            instanceOrganizationLogo.Value   = vm.INSTANCE_ORGANIZATION_LOGO;
            instanceOrganizationUrl.Value    = vm.INSTANCE_ORGANIZATION_URL;
            instanceEduUseText.Value         = vm.INSTANCE_EDU_USE_TEXT;
            instanceAllowRegistrations.Value = Convert.ToString(vm.INSTANCE_ALLOW_USER_REGISTRATION);

            var confs = new List <DataFlow.Models.Configuration>
            {
                apiServerUrl,
                apiServerKey,
                apiServerSecret,
                instanceOrganizationLogo,
                instanceOrganizationUrl,
                instanceEduUseText,
                instanceAllowRegistrations
            };

            ConfigurationService.SaveConfiguration(confs);
            ConfigurationService.FillSwaggerMetadata(apiServerUrl.Value);

            vm.FormResult.ShowInfoMessage = true;
            vm.FormResult.IsSuccess       = true;
            vm.FormResult.InfoMessage     = "Application configuration saved!";

            LogService.Info("Configuration was modified.");

            return(View(vm));
        }
        public DataFlow.Web.Models.ApiConfigurationValues GetConfiguration()
        {
            var conf = new DataFlow.Web.Models.ApiConfigurationValues
            {
                API_SERVER_URL                   = GetConfigurationByKey(Constants.API_SERVER_URL).Value,
                API_SERVER_KEY                   = GetConfigurationByKey(Constants.API_SERVER_KEY).Value,
                API_SERVER_SECRET                = GetConfigurationByKey(Constants.API_SERVER_SECRET).Value,
                INSTANCE_ORGANIZATION_LOGO       = GetConfigurationByKey(Constants.INSTANCE_ORGANIZATION_LOGO).Value,
                INSTANCE_ORGANIZATION_URL        = GetConfigurationByKey(Constants.INSTANCE_ORGANIZATION_URL).Value,
                INSTANCE_EDU_USE_TEXT            = GetConfigurationByKey(Constants.INSTANCE_EDU_USE_TEXT).Value,
                INSTANCE_ALLOW_USER_REGISTRATION = Convert.ToBoolean(GetConfigurationByKey(Constants.INSTANCE_ALLOW_USER_REGISTRATION).Value)
            };

            return(conf);
        }