BotSharp/Bot.Rasa.RestApi/AgentController.cs

34 lines
744 B
C#
Raw Normal View History

2017-12-30 20:26:35 +00:00
using Bot.Rasa.Agents;
using Bot.Rasa.Console;
2018-01-02 18:05:35 +00:00
using EntityFrameworkCore.BootKit;
2017-12-30 20:26:35 +00:00
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
2018-01-02 18:05:35 +00:00
using System.Linq;
2017-12-30 20:26:35 +00:00
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)
{
2018-01-02 18:05:35 +00:00
var console = new RasaConsole(dc);
2017-12-30 20:26:35 +00:00
2018-01-02 18:05:35 +00:00
dc.DbTran(() => {
console.CreateAgent(agent);
2017-12-30 20:26:35 +00:00
});
return agent.Id;
}
}
}