- AppSettings.AutoTakeOwnership bool property defaulting to false - PermissionEntry.WasAutoElevated optional param (default false, last position) - SettingsService.SetAutoTakeOwnershipAsync persists toggle - IOwnershipElevationService interface + OwnershipElevationService wrapping Tenant.SetSiteAdmin - SettingsViewModel.AutoTakeOwnership property loads and persists via SetAutoTakeOwnershipAsync - DI registration in App.xaml.cs (Phase 18 section) - 8 new tests: models, persistence, service, viewmodel
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using SharepointToolbox.Core.Models;
|
|
using SharepointToolbox.Infrastructure.Persistence;
|
|
|
|
namespace SharepointToolbox.Services;
|
|
|
|
public class SettingsService
|
|
{
|
|
private readonly SettingsRepository _repository;
|
|
|
|
private static readonly HashSet<string> SupportedLanguages = new(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
"en", "fr"
|
|
};
|
|
|
|
public SettingsService(SettingsRepository repository)
|
|
{
|
|
_repository = repository;
|
|
}
|
|
|
|
public Task<AppSettings> GetSettingsAsync()
|
|
=> _repository.LoadAsync();
|
|
|
|
public async Task SetLanguageAsync(string cultureCode)
|
|
{
|
|
if (!SupportedLanguages.Contains(cultureCode))
|
|
throw new ArgumentException($"Unsupported language code '{cultureCode}'. Supported: en, fr.", nameof(cultureCode));
|
|
|
|
var settings = await _repository.LoadAsync();
|
|
settings.Lang = cultureCode;
|
|
await _repository.SaveAsync(settings);
|
|
}
|
|
|
|
public async Task SetDataFolderAsync(string path)
|
|
{
|
|
var settings = await _repository.LoadAsync();
|
|
settings.DataFolder = path;
|
|
await _repository.SaveAsync(settings);
|
|
}
|
|
|
|
public async Task SetAutoTakeOwnershipAsync(bool enabled)
|
|
{
|
|
var settings = await _repository.LoadAsync();
|
|
settings.AutoTakeOwnership = enabled;
|
|
await _repository.SaveAsync(settings);
|
|
}
|
|
}
|