2023-06-11 23:46:02 +00:00
|
|
|
using BotSharp.Abstraction.Agents;
|
|
|
|
|
using BotSharp.Abstraction.ApiAdapters;
|
|
|
|
|
using BotSharp.Core.Agents.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Agents;
|
|
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class AgentController : ControllerBase, IApiAdapter
|
|
|
|
|
{
|
|
|
|
|
private readonly IAgentService _agentService;
|
|
|
|
|
public AgentController(IAgentService agentService)
|
|
|
|
|
{
|
|
|
|
|
_agentService = agentService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost("/agent")]
|
2023-06-12 13:28:49 +00:00
|
|
|
public async Task<AgentViewModel> CreateAgent(AgentCreationModel agent)
|
2023-06-11 23:46:02 +00:00
|
|
|
{
|
2023-06-12 13:28:49 +00:00
|
|
|
var createdAgent = await _agentService.CreateAgent(agent.ToAgent());
|
|
|
|
|
return AgentViewModel.FromAgent(createdAgent);
|
2023-06-11 23:46:02 +00:00
|
|
|
}
|
|
|
|
|
}
|