/// <summary> /// Create a new appsetting /// </summary> /// <param name="model">AppSetting Model</param> /// <returns></returns> public async Task <BaseComponentResultRp> CreateAppSetting(AppSettingPostRp model) { var result = new BaseComponentResultRp(); var createdBy = this._identityGateway.GetIdentity(); var appSetting = AppSettingEntity.Factory.Create(model.Key, model.Value, true, DateTime.UtcNow, createdBy); var entity = await this._dbContext.AppSettings.FirstOrDefaultAsync(c => c.Key.Equals(model.Key)); if (entity != null) { result.AddConflict($"The Key {model.Key} has already been taken."); return(result); } await this._dbContext.AddAsync(appSetting); await this._dbContext.SaveChangesAsync(); result.AddResult("Key", appSetting.Key); return(result); }
/// <summary> /// Create a new appsetting /// </summary> /// <param name="model">AppSetting Model</param> /// <returns></returns> public async Task <BaseComponentResultRp> CreateAppSetting(AppSettingPostRp model) { var result = new BaseComponentResultRp(); var createdBy = this._identityService.GetIdentity(); var appSetting = AppSettingEntity.Factory.Create(model.Key, model.Value, true, createdBy); var entity = await this._appSettingRepository.GetAppSettingByKey(model.Key); if (entity != null) { result.AddConflict($"The Key {model.Key} has already been taken."); return(result); } this._appSettingRepository.Add(appSetting); await this._appSettingRepository.SaveChanges(); result.AddResult("Key", appSetting.Key); return(result); }