BotSharp/Bot.Rasa.RestApi/AgentController.cs
2018-03-18 21:07:36 -05:00

34 lines
745 B
C#

using Bot.Rasa.Agents;
using Bot.Rasa.Consoles;
using EntityFrameworkCore.BootKit;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Bot.Rasa.RestApi
{
public class AgentController : EssentialController
{
[HttpGet("id")]
public Agent Get([FromRoute] String id)
{
var console = new RasaConsole(dc);
return console.LoadAgent(id);
}
[HttpPost]
public String Create([FromBody] Agent agent)
{
var console = new RasaConsole(dc);
dc.DbTran(() => {
console.CreateAgent(agent);
});
return agent.Id;
}
}
}