@inject SavePathService SavePathService @inject ArchiveService ArchiveService @inject IMessageService MessageService @inject ILogger Logger @if (context.Type == SavePathType.Registry) { } else { }
@code { [CascadingParameter(Name = "GameId")] public Guid GameId { get; set; } Archive _archive; ICollection _savePaths = new List(); protected override async Task OnInitializedAsync() { _archive = await ArchiveService.GetLatestArchiveAsync(a => a.GameId == GameId); await LoadPaths(); } async Task LoadPaths() => _savePaths = await SavePathService.GetAsync(p => p.GameId == GameId); void AddPath() { _savePaths.Add(new SavePath { GameId = GameId, WorkingDirectory = "{InstallDir}" }); } async Task RemovePath(SavePath path) { await SavePathService.DeleteAsync(path); await LoadPaths(); } public async Task Save() { try { foreach (var savePath in _savePaths) { if (savePath.Id == Guid.Empty) await SavePathService.AddAsync(savePath); else await SavePathService.UpdateAsync(savePath); } MessageService.SuccessAsync("Save paths updated!"); } catch (Exception ex) { MessageService.ErrorAsync("Could not update save paths!"); Logger.LogError(ex, "Could not update save paths!"); } await LoadPaths(); } }