Skip to content

Commit

Permalink
Enabling all trees for demo mode. Closes #273.
Browse files Browse the repository at this point in the history
  • Loading branch information
impworks committed Jan 14, 2024
1 parent c58b513 commit de90684
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Bonsai/Code/Config/Startup.Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Serilog;

namespace Bonsai.Code.Config
Expand Down Expand Up @@ -104,6 +105,20 @@ private void InitDatabase(IApplicationBuilder app)
await SeedData.EnsureDefaultUserCreatedAsync(sp.GetService<UserManager<AppUser>>());
});
}

startupService.AddTask(
"PrepareConfig",
"Настройка конфигурации",
async () =>
{
var db = sp.GetRequiredService<AppDbContext>();
var wrapper = await db.DynamicConfig.FirstAsync();
var cfg = JsonConvert.DeserializeObject<DynamicConfig>(wrapper.Value);
cfg.TreeKinds = TreeKind.FullTree | TreeKind.CloseFamily | TreeKind.Ancestors | TreeKind.Descendants;
wrapper.Value = JsonConvert.SerializeObject(cfg);
await db.SaveChangesAsync();
}
);
}

startupService.AddTask(
Expand Down

0 comments on commit de90684

Please sign in to comment.