Enhance DataController and BotService with new configuration and bot name checks
- Added IConfiguration dependency to DataController for environment variable access. - Updated GetPaginatedAgentSummariesCommand to include a flag for filtering profitable agents. - Implemented HasUserBotWithNameAsync method in IBotService and BotService to check for existing bots by name. - Modified StartBotCommandHandler and StartCopyTradingCommandHandler to prevent duplicate bot names during strategy creation.
This commit is contained in:
@@ -54,6 +54,15 @@ namespace Managing.Application.ManageBot
|
||||
"You cannot create multiple strategies on the same ticker.");
|
||||
}
|
||||
|
||||
// Check if user already has a bot with this name
|
||||
var hasExistingBotWithName = await _botService.HasUserBotWithNameAsync(request.User.Id, request.Config.Name);
|
||||
if (hasExistingBotWithName)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"You already have a strategy running or saved with the name '{request.Config.Name}'. " +
|
||||
"You cannot create multiple strategies with the same name.");
|
||||
}
|
||||
|
||||
Account account;
|
||||
if (string.IsNullOrEmpty(request.Config.AccountName))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user