Add GetBotByUserIdAndNameAsync method to IBotService and BotService

- Implemented GetBotByUserIdAndNameAsync in IBotService and BotService to retrieve a bot by user ID and name.
- Updated GetUserStrategyCommandHandler to utilize the new method for fetching strategies based on user ID.
- Added corresponding method in IBotRepository and PostgreSqlBotRepository for database access.
This commit is contained in:
2025-11-22 10:46:07 +07:00
parent 476bcebfe9
commit 269bbfaab0
5 changed files with 31 additions and 3 deletions

View File

@@ -162,6 +162,17 @@ public class PostgreSqlBotRepository : IBotRepository
return PostgreSqlMappers.Map(entity);
}
public async Task<Bot> GetBotByUserIdAndNameAsync(int userId, string name)
{
var entity = await _context.Bots
.AsNoTracking()
.Include(m => m.User)
.Include(m => m.MasterBotUser)
.FirstOrDefaultAsync(b => b.UserId == userId && b.Name == name)
.ConfigureAwait(false);
return PostgreSqlMappers.Map(entity);
}
public async Task<IEnumerable<Bot>> GetBotsByIdsAsync(IEnumerable<Guid> identifiers)
{
try