Пример #1
0
        public void MapsRegularValues()
        {
            var response = (dynamic)target.MapToEditConfig(new ConfigInstance <SampleConfig>(sample, clientId), definition);

            Assert.Equal(sample.Choice, response.Choice);
            Assert.Equal(sample.IsLlamaFarmer, response.IsLlamaFarmer);
            Assert.Equal(sample.Decimal, response.Decimal);
            Assert.Equal(sample.LlamaCapacity, response.LlamaCapacity);
            Assert.Equal(sample.Name, response.Name);
        }
Пример #2
0
        public object MapUploadToEditModel(string json, ConfigurationIdentity identity, ConfigurationModel model)
        {
            var uploadedInstance = uploadMapper.MapToConfigInstance(json, identity, model);

            if (uploadedInstance.GetConfiguration() == null)
            {
                uploadedInstance.SetConfiguration(uploadedInstance.ConstructNewConfiguration());
            }
            return(configurationEditModelMapper.MapToEditConfig(uploadedInstance, model));
        }
Пример #3
0
 private Task HandleValueRequest(HttpContext context, ConfigInstance configInstance)
 {
     if (context.Request.Method == "GET")
     {
         return(responseFactory.BuildResponse(context, configurationEditModelMapper.MapToEditConfig(configInstance, GetConfigurationSetForModel(configInstance))));
     }
     if (context.Request.Method == "POST")
     {
         return(HandleValuePostRequest(context, configInstance));
     }
     throw new System.Exception("Only Get or Post methods expected");
 }
        private async Task HandleGetRequest(HttpContext context, ConfigurationClient client, string configType)
        {
            var configInstance = await configInstanceRouter.GetConfigInstanceOrDefault(client, configType);

            if (configInstance == null)
            {
                httpResponseFactory.BuildNotFoundStatusResponse(context);
            }
            else
            {
                await httpResponseFactory.BuildJsonResponse(context, configurationEditModelMapper.MapToEditConfig(configInstance, GetConfigurationModel(configInstance)));
            }
        }