public async Task SetupActiveRuleset() { using var factory = _dbContextHelper.GetFactory(); var dbContext = factory.GetDbContext(); var ruleset = await dbContext.Rulesets.FirstOrDefaultAsync(r => r.IsActive == true); if (ruleset == null) { _logger.LogError($"Failed to setup active ruleset: no ruleset found"); return; } ActiveRuleset = ruleset; ActiveRuleset.ActionRules = await dbContext.RulesetActionRules.Where(r => r.RulesetId == ruleset.Id).ToListAsync(); ActiveRuleset.ItemCategoryRules = await dbContext.RulesetItemCategoryRules.Where(r => r.RulesetId == ruleset.Id).ToListAsync(); foreach (var rule in ActiveRuleset.ItemCategoryRules) { rule.ItemCategory = await _itemCategoryService.GetWeaponItemCategoryAsync(rule.ItemCategoryId); } _logger.LogInformation($"Active ruleset loaded: {ActiveRuleset.Name}"); }