BotSharp/Bot.Rasa/Entities/EntityTypeExtension.cs
haiping008@gmail.com 33d42ae035 1. Added context in/ out, lifespan.
2. Import agent in Dialogflow format.
3. Lazy training per input contexts.
2018-03-21 16:07:43 -05:00

30 lines
854 B
C#

using Bot.Rasa.Agents;
using EntityFrameworkCore.BootKit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Bot.Rasa.Entities
{
public static class EntityTypeExtension
{
public static string CreateEntityType(this Agent agent, Database dc, Entity entityType)
{
if (dc.Table<Entity>().Any(x => x.Name == entityType.Name && x.AgentId == agent.Id)) return agent.Id;
dc.Table<Entity>().Add(entityType);
return entityType.Id;
}
public static void DeleteEntityType(this Agent agent, Database dc, String entityTypeId)
{
var entityType = dc.Table<Entity>().FirstOrDefault(x => x.Id == entityTypeId);
if (entityType == null) return;
dc.Table<Entity>().Remove(entityType);
}
}
}