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); }
public async Task <IActionResult> AddAsync([NotNull, FromBody] CrispyVariableAddtionContext context) { await VariableService.AddAsync(context); return(Ok()); }