Get agent list.
This commit is contained in:
parent
2dd93aef42
commit
578ba15ef5
|
|
@ -8,6 +8,7 @@ namespace BotSharp.Abstraction.Agents;
|
|||
public interface IAgentService
|
||||
{
|
||||
Task<Agent> CreateAgent(Agent agent);
|
||||
Task<List<Agent>> GetAgents();
|
||||
Task<bool> DeleteAgent(string id);
|
||||
Task UpdateAgent(Agent agent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,11 @@ public class AgentController : ControllerBase, IApiAdapter
|
|||
var createdAgent = await _agentService.CreateAgent(agent.ToAgent());
|
||||
return AgentViewModel.FromAgent(createdAgent);
|
||||
}
|
||||
|
||||
[HttpGet("/agents")]
|
||||
public async Task<List<AgentViewModel>> GetAgents()
|
||||
{
|
||||
var agents = await _agentService.GetAgents();
|
||||
return agents.Select(x => AgentViewModel.FromAgent(x)).ToList();
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,15 @@ public class AgentService : IAgentService
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<List<Agent>> GetAgents()
|
||||
{
|
||||
var db = _services.GetRequiredService<AgentDbContext>();
|
||||
var query = from agent in db.Agent
|
||||
where agent.OwnerId == _user.Id
|
||||
select agent.ToAgent();
|
||||
return query.ToList();
|
||||
}
|
||||
|
||||
public Task UpdateAgent(Agent agent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
|||
Loading…
Reference in a new issue