Esempio n. 1
0
        public async Task <VisitorsConfigData> GetItemAsync()
        {
            VisitorsConfigData config = await DataProvider.GetAsync(KEY);

            if (config == null)
            {
                config = new VisitorsConfigData();
                await AddConfigAsync(config);
            }
            return(config);
        }
Esempio n. 2
0
 private async Task AddConfigAsync(VisitorsConfigData data)
 {
     data.Id = KEY;
     if (!await DataProvider.AddAsync(data))
     {
         throw new InternalError("Unexpected error adding settings");
     }
     await Auditing.AddAuditAsync($"{nameof(VisitorsConfigDataProvider)}.{nameof(AddConfigAsync)}", "Config", Guid.Empty,
                                  "Add Visitors Config",
                                  DataBefore : null,
                                  DataAfter : data,
                                  ExpensiveMultiInstance : true
                                  );
 }
Esempio n. 3
0
        public async Task UpdateConfigAsync(VisitorsConfigData data)
        {
            VisitorsConfigData 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 configuration {0}", status);
            }
            await Auditing.AddAuditAsync($"{nameof(VisitorsConfigDataProvider)}.{nameof(UpdateConfigAsync)}", "Config", Guid.Empty,
                                         "Update Visitors Config",
                                         DataBefore : origConfig,
                                         DataAfter : data,
                                         ExpensiveMultiInstance : true
                                         );
        }