I’m obviously doing something wrong here but can’t figure it out. Following this article: ServiceStack How to call my service from code, I’m attempting to call another method (old way, new way, from article) from within a method such as:
public async Task<object> Post(CreateEnvironment request)
{
try
{
var environment = request.ConvertTo<Environment>();
await Db.InsertAsync(environment);
await HostContext.ServiceController.ExecuteAsync(new SetupEnvironment() { EnvironmentId = environment.Id }, base.Request);
await Gateway.SendAsync(new SetupEnvironment { EnvironmentId = environment.Id });
return environment;
}
catch (Exception)
{
throw;
}
}
The “ExecuteAsync” and “SendAsync” are the one’s I’m trying to use but the following code in Startup is not firing:
RegisterTypedRequestFilter<IForEnvironment>((req, res, requestDto) =>
{
var connectionString = $"Server=localhost;User Id=postgres;Password=asdfsf;Database={requestDto.EnvironmentId:N};Pooling=true;MinPoolSize=0;MaxPoolSize=200";
req.Items[Keywords.DbInfo] = new ConnectionInfo() { ConnectionString = connectionString };
});
So I’m unable to change the connection string per execution. The RequestDTO is defined as:
public class SetupEnvironment : IReturnVoid, IForEnvironment
{
public Guid EnvironmentId { get; set; }
}
What am I missing?