示例#1
0
        /// <summary>
        /// Create application.
        /// </summary>
        /// <param name="info">Indicating the application configuration information.</param>
        /// <returns>Async response.</returns>
        public async Task <AppResponse> CreateAppConfigurationAsync(AppConfigurationInfo info)
        {
            string url      = this.GenerateApiEndpoint("apps", "configurations");
            var    response = await this.httpClient.SendAsyncWithException <AppConfigurationInfo, AppResponse>(HttpMethod.Post, url, info);

            return(response);
        }
示例#2
0
        public async Task <IHttpActionResult> CreateAppConfiguration([FromBody] AppConfigurationInfo info, CancellationToken token)
        {
            CustomTrace.TraceInformation("[CreateAppConfiguration] AppId={0}", info.AppId);

            var appConfiguration = await this.Database.AppConfigurations.GetSingleAsync(info.AppId, token);

            if (appConfiguration == null)
            {
                appConfiguration = new AppConfigurationEntity
                {
                    Id            = info.AppId,
                    Configuration = info.Configuration,
                };

                await this.Database.AppConfigurations.InsertAsync(appConfiguration, token);
            }
            else
            {
                await this.Database.AppConfigurations.UpsertAsync(appConfiguration, token);
            }

            var response = new AppConfigurationResponse
            {
                AppId         = info.AppId,
                Configuration = info.Configuration
            };

            return(this.CreateSuccessResult(response));
        }
        public async Task E2E_AppClient_GetAppConfiguration_Test()
        {
            var conf = new TestAppConfiguration()
            {
                Foo = "foo",
                Bar = "bar"
            };
            var appConfigurationInfo = new AppConfigurationInfo()
            {
                AppId         = TestAppId,
                Configuration = JsonConvert.SerializeObject(conf)
            };
            await asClient.CreateAppConfigurationAsync(appConfigurationInfo);

            var result = await acClient.GetAppConfigurationAsync(TestAppId);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.AppId, TestAppId);
            CheckEquals(conf, JsonConvert.DeserializeObject <TestAppConfiguration>(result.Configuration));
        }