public async Task <SearchConfigData> GetItemAsync() { SearchConfigData config = await DataProvider.GetAsync(KEY); if (config == null) { config = new SearchConfigData(); await AddConfigAsync(config); } return(config); }
private async Task AddConfigAsync(SearchConfigData data) { data.Id = KEY; if (!await DataProvider.AddAsync(data)) { throw new InternalError("Unexpected error adding settings"); } await Auditing.AddAuditAsync($"{nameof(SearchConfigDataProvider)}.{nameof(AddConfigAsync)}", "Config", Guid.Empty, "Add Search Config", DataBefore : null, DataAfter : data, ExpensiveMultiInstance : true ); }
public async Task UpdateConfigAsync(SearchConfigData data) { SearchConfigData origConfig = Auditing.Active ? await GetItemAsync() : null; data.Id = KEY; UpdateStatusEnum status = await DataProvider.UpdateAsync(data.Id, data.Id, data); if (status != UpdateStatusEnum.OK) { throw new InternalError("Unexpected error saving settings {0}", status); } await Auditing.AddAuditAsync($"{nameof(SearchConfigDataProvider)}.{nameof(UpdateConfigAsync)}", "Config", Guid.Empty, "Update Search Config", DataBefore : origConfig, DataAfter : data, ExpensiveMultiInstance : true ); }