BotSharp/BotSharp.RestApi/AgentController.cs

39 lines
916 B
C#
Raw Normal View History

2018-03-28 22:08:49 +00:00
using BotSharp.Core.Agents;
using BotSharp.Core.Engines;
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;
2018-03-28 22:08:49 +00:00
namespace BotSharp.Core.RestApi
2017-12-30 20:26:35 +00:00
{
public class AgentController : EssentialController
{
[HttpGet("id")]
public Agent Get([FromRoute] String id)
{
2018-03-28 22:08:49 +00:00
var console = new RasaAi(dc, null);
return console.LoadAgent();
2017-12-30 20:26:35 +00:00
}
2018-03-28 22:08:49 +00:00
/// <summary>
/// New agent with basic configuration
/// </summary>
/// <param name="agent"></param>
/// <returns></returns>
2017-12-30 20:26:35 +00:00
[HttpPost]
public String Create([FromBody] Agent agent)
{
2018-03-28 22:08:49 +00:00
var rasa = new RasaAi(dc, null);
2017-12-30 20:26:35 +00:00
2018-01-02 18:05:35 +00:00
dc.DbTran(() => {
2018-03-28 22:08:49 +00:00
rasa.SaveAgent(agent);
2017-12-30 20:26:35 +00:00
});
return agent.Id;
}
}
}