BotSharp/Bot.Rasa.RestApi/AgentController.cs

34 lines
733 B
C#
Raw Normal View History

2017-12-30 20:26:35 +00:00
using Bot.Rasa.Agents;
2018-03-19 02:07:36 +00:00
using Bot.Rasa.Consoles;
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 RasaAi(dc);
2017-12-30 20:26:35 +00:00
return console.LoadAgent(id);
}
[HttpPost]
public String Create([FromBody] Agent agent)
{
var console = new RasaAi(dc);
2017-12-30 20:26:35 +00:00
2018-01-02 18:05:35 +00:00
dc.DbTran(() => {
console.SaveAgent(agent);
2017-12-30 20:26:35 +00:00
});
return agent.Id;
}
}
}