public async void Add(Terminal terminal) { var hostTenant = await context.TryGetAsync("tenant-host").ConfigureAwait(false); var optionsBuilder = new DbContextOptionsBuilder <NextAppContext>(); optionsBuilder.UseNpgsql(hostTenant.ConnectionString); var db = new NextAppContext(hostTenant, optionsBuilder.Options); //TODO validation db.EnsureAutoHistory(); db.Terminals.Add(terminal); await db.SaveChangesAsync(); }
private async Task Init() { tenantInfo = await context.TryGetAsync(id).ConfigureAwait(false); if (tenantInfo is null) { throw new ArgumentNullException(nameof(tenantInfo)); } }
public async Task Consume(ConsumeContext <TenantCreatedNotDefault> context) { //TODO exceptions log.LogInformation($"NonDefault Tenant created with id: '{context.Message.Id}' on: '{context.Message.CreationTime.ToString()}'"); // throw new NotImplementedException(); var tenantInfo = await store.TryGetAsync(context.Message.Id); if (tenantInfo is null) { log.LogInformation($"Failed to prepare database for Tenant with id: '{context.Message.Id}' on: '{context.Message.CreationTime.ToString()}'"); return; } var builder = new DbContextOptionsBuilder <NextAppContext>().UseNpgsql(tenantInfo.ConnectionString); using (var db = new NextAppContext(tenantInfo, builder.Options)) { db.Database.EnsureCreated(); db.Database.Migrate(); } log.LogInformation($"Prepared database for Tenant with id: '{context.Message.Id}' on: '{context.Message.CreationTime.ToString()}'"); }
public async Task <TTenantInfo> TryGetAsync(string id) { return(await store.TryGetAsync(id)); }
public async Task <TenantInfo> TryGetAsync(string id) => await _tenantStore.TryGetAsync(id);