Ejemplo n.º 1
0
        public async Task <CrispyVariable> AddAsync([NotNull] CrispyVariableAddtionContext context)
        {
            if (await Query().AnyAsync(x => x.ApplicationId == context.ApplicationId && x.Key == context.Key))
            {
                throw new ArgumentException($"{ (context.ApplicationId == null ? "全局配置" : "当前环境")}已存在 Key 为 {context.Key} 的配置项");
            }

            var variable = new CrispyVariable(context.ApplicationId, context.Key, context.Value);

            Store.Variables.Add(variable);

            await SaveChangesAsync();

            return(variable);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddAsync([NotNull, FromBody] CrispyVariableAddtionContext context)
        {
            await VariableService.AddAsync(context);

            return(Ok());
        }